cognito-kakao-example
cognito-kakao-example copied to clipboard
This repository is an example code for creating Amazon Cognito user via Kakaotalk signin
cognito-kakao-integration-example
NOTE: If you're looking for a solution using OIDC, please visit oidc branch on this repository.
This repository is an example code for creating Amazon Cognito user via Kakaotalk signin
Deploying this cdk will provision below resources on you AWS Account.

Signup

Signin

Prerequisites
- awscli
- Nodejs 16+
- AWS Account and Locally configured AWS credential
Installation
this repository consists of 2 parts
- infra - provision AWS resources such as Cognito UserPool, ApiGateway, etc.
- web - run Nextjs web service on locally to test Kakao signin
Infra
- Install project dependencies
$ cd infra
$ npm i
- Install cdk in global context and run
cdk bootstrapif you did not initailize cdk yet.
$ npm i -g [email protected]
$ cdk bootstrap
-
open /infra/config/dev.toml and replace values for your environment
-
copy
dev.tomlfile under infra folder with name.toml
$ cp config/dev.toml .toml
- Deploy CDK Stacks on AWS
$ cdk deploy "*" --require-approval never
Web
- visit Kakao Developer Console and create your app
Cognito requires user email to register user, so you should add email to scope on Kakao Login
- register web platform url with
http://localhost:3000

- enable
Kakao Loginand set redirect uri withhttp://localhost:3000

-
copy
Javascript KeyandREST API Keyon your app summary page -
open /web/lib/interfaces/config.ts and edit below variables:
- AmplifyConfig.UserPoolId - check out your AWS console or output of
cdk deployat infra - AmplifyConfig.UserPoolWebClientId - check out your AWS console or output of
cdk deployat infra - ApiHash - check out your AWS console or output of
cdk deployat infra - IdentityProvider.Kakao.AppKey - paste
Javascript Keyat Kakao Developer Console - IdentityProvider.Kakao.ApiKey - paste
REST API Keyat Kakao Developer Console
- Install dependencies
$ cd web
$ npm i
Usage
- run dev server
$ cd web
$ npm run dev
-
visit http://localhost:3000 and click kakao login button
-
login at redirected kakako page
-
alert should be displayed (open browser console to find the access token received from Kakaotalk)
-
visit Amazon Cognito UserPool console page
-
user and group should be created

Cleanup
destroy provisioned cloud resources
$ cd infra
$ cdk destroy "*"
