@openauth/kakao
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Open Auth - Kakao

Downloads Version License Typescript dependencies Status

@openauth/kakao is an implementation of Kakao OAuth.

Installation

npm i @openauth/kakao

Usage

import { KakaoOAuth } from '@openauth/kakao'

const oauth = new KakaoOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/kakao/callback',
})

OAuth login link.

oauth.getAuthRequestUri() // print https://kauth.kakao.com/oauth/authorize?...

After logging in, you will be redirected to the redirectUri page with the code value.

const code = 'AQAO3q3...'

const response = await oauth.getAccessTokenResponse(code)
console.log(response) // { accessToken: '...', refreshToken: '...', tokenType: 'bearer', expiresIn: 21599, refreshTokenExpiresIn: 5183999 }

Save accessToken and use it when requesting API.

const user = await oauth.getAuthUser(response.accessToken)
console.log(user) // { id: '3000000', email: '...', nickname: '...' }

Package Sidebar

Install

npm i @openauth/kakao

Weekly Downloads

27

Version

0.4.0

License

MIT

Unpacked Size

15.2 kB

Total Files

19

Last publish

Collaborators

  • wan2land