Skip to content

dango0812/nextauth-cognito

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

59 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


NextAuth with AWS Cognito

This is a NextAuth with AWS Cognito Email & Google Sign in sample code
See description and cognito environment configuration for the documentation


0904011749281802

(1) NextAuth & AWS Cognito env setup

NEXTAUTH_URL=
NEXTAUTH_SECRET=
# NEXTAUTH_SECRET use uuid4 or your secret key
# uuid online create: https://www.uuidgenerator.net/version4
# nextauth docs: (https://next-auth.js.org/configuration/options#secret)

NEXT_PUBLIC_AWS_COGNITO_CLIENT_ID=
NEXT_PUBLIC_AWS_COGNITO_USER_POOL_ID=
NEXT_PUBLIC_AWS_COGNITO_DOMAIN_URL=
NEXT_PUBLIC_AWS_COGNITO_IDP_URL=
NEXT_PUBLIC_AWS_COGNITO_REGION=

(2) Please register your callback URL in AWS Cognito & Google Cloud Platform

Email callback url: {your domain}/sign-in
OpenID callback url: {your domain}/api/auth/callback/cognito

(3) Configure the OpenID Connect scope in the AWS Cognito Userpool

AWS Cognito Userpool OpenID Connect Scope Types: openid, email, profile, phone, aws.cognito.signin.user.admin
Please modify the authorization -> scope in the api/auth/[...nextauth] file after setting it up for your environment
πŸ’‘ If you are using an AWS Cognito client secret key, use the secret key value provided by Cognito instead of null

Version used in the development-environment

Generic badge Generic badge Generic badge
Generic badge Generic badge Generic badge

Get started

$ git clone https://github.com/dango0812/nextauth-cognito.git
$ cd nextauth-cognito
$ cd javascript or typescript
$ pnpm install
$ pnpm dev

You can find a more detailed explanation on my blog

Thank you. 🫠

About

NextAuth + AWS Cognito Email & Google Login Example, also provide blog posts for detail explanation πŸ‰

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published