Skip to content

Latest commit

 

History

History
122 lines (75 loc) · 2.8 KB

README.md

File metadata and controls

122 lines (75 loc) · 2.8 KB

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

  1. Install project dependencies
$ cd infra
$ npm i
  1. Install cdk in global context and run cdk bootstrap if you did not initailize cdk yet.
$ npm i -g [email protected]
$ cdk bootstrap
  1. open /infra/config/dev.toml and replace values for your environment

  2. copy dev.toml file under infra folder with name .toml

$ cp config/dev.toml .toml
  1. Deploy CDK Stacks on AWS
$ cdk deploy "*" --require-approval never

Web

  1. 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

  1. register web platform url with http://localhost:3000

  1. enable Kakao Login and set redirect uri with http://localhost:3000

  1. copy Javascript Key and REST API Key on your app summary page

  2. open /web/lib/interfaces/config.ts and edit below variables:

  • AmplifyConfig.UserPoolId - check out your AWS console or output of cdk deploy at infra
  • AmplifyConfig.UserPoolWebClientId - check out your AWS console or output of cdk deploy at infra
  • ApiHash - check out your AWS console or output of cdk deploy at infra
  • IdentityProvider.Kakao.AppKey - paste Javascript Key at Kakao Developer Console
  • IdentityProvider.Kakao.ApiKey - paste REST API Key at Kakao Developer Console
  1. Install dependencies
$ cd web
$ npm i

Usage

  1. run dev server
$ cd web
$ npm run dev
  1. visit http://localhost:3000 and click kakao login button

  2. login at redirected kakako page

  3. alert should be displayed (open browser console to find the access token received from Kakaotalk)

  4. visit Amazon Cognito UserPool console page

  5. user and group should be created

Cleanup

destroy provisioned cloud resources

$ cd infra
$ cdk destroy "*"