/cognito-kakao-example

Primary LanguageTypeScriptMIT LicenseMIT

cognito-kakao-integration-example

This repository is about example code for creating Amazon Cognito user via kakaotalk signin

Deploying this cdk will provision below architeture on you AWS Account.

Signup

Signin

Prerequisites

  • awscli
  • Nodejs 10.x+
  • Python 3.4+
  • 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 init if you did not initailize cdk yet.

$ npm i -g cdk@1.119.0
$ cdk bootstrap

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 on your app summary page

  2. open config.ts and edit below variables:

  • AmplifyConfig.UserPoolId - check out console or output of cdk deploy at infra
  • AmplifyConfig.UserPoolWebClientId - check out console or output of cdk deploy at infra
  • ApiHash - check out console or output of cdk deploy at infra
  • IdentityProvider.Kakao.AppKey - paste Javascript 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

  4. visit Amazon Cognito UserPool console page

  5. user and group should be created

Cleanup

destroy provisioned cloud resources

$ cd infra
$ cdk destroy "*"