@openauth/naver
v0.4.0
Published
OAuth naver library.
Downloads
120
Maintainers
Readme
Open Auth - Naver
@openauth/naver is an implementation of Naver OAuth.
Installation
npm i @openauth/naver
Usage
import { NaverOAuth } from '@openauth/naver'
const oauth = new NaverOAuth({
clientId: 'client_id',
clientSecret: 'client_secret',
redirectUri: 'https://wani.kr/auth/naver/callback',
})
OAuth login link.
oauth.getAuthRequestUri() // print https://nid.naver.com/oauth2.0/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: 3600 }
Save accessToken
and use it when requesting API.
const user = await oauth.getAuthUser(response.accessToken)
console.log(user) // { id: '3000000', email: '...', name: '...' }