Cognito Provider
Resources
Setup
Callback URL
https://example.com/api/auth/callback/cognito
Environment Variables
AUTH_COGNITO_ID
AUTH_COGNITO_SECRET
AUTH_COGNITO_ISSUER
Configuration
/auth.ts
import NextAuth from "next-auth"
import Cognito from "next-auth/providers/cognito"
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Cognito],
})
Notes
You need to select your AWS region to go the the Cognito dashboard.
The issuer is a URL, that looks like this: https://cognito-idp.{region} .amazonaws.com/{PoolId}
, where PoolId
is from General Settings in Cognito, not
to be confused with the App Client ID.
⚠️
Make sure you select all the appropriate client settings or the OAuth flow will not work.