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

0.4.0 • Public • Published

Open Auth - Naver

Downloads Version License Typescript dependencies Status

@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: '...' }

Package Sidebar

Install

npm i @openauth/naver

Weekly Downloads

16

Version

0.4.0

License

MIT

Unpacked Size

13.2 kB

Total Files

19

Last publish

Collaborators

  • wan2land