@openauth/kakao
v0.4.0
Published
OAuth kakao library.
Downloads
128
Maintainers
Readme
Open Auth - Kakao
@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: '...' }