2.0.0 • Published 6 years ago
naver-id-login v2.0.0
Prerequisites
- Register application at https://developers.naver.com/apps/#/register
- Select the "네아로 (네이버 아이디로 로그인)" API
- Store the "Client ID"
Installation
$ npm install naver-id-loginUsage
Initialization
import naver from 'naver-id-login'Login
A new popup window opens where the user is promted to type in their username and password
login(clientId: string, callbackUrl: string): Promise\<Login>
const clientId = process.env.NAVER_CLIENT_ID
const callbackUrl = 'http://localhost:8080/callback/naver'
const auth = await naver.login(clientId, callbackUrl)Login response object
{
access_token: string
expires_in: string // e.g. "3600"
state: string
token_type: string // "bearer"
}Login window close error object
{
code: string // "popup-closed"
message: string // "The popup has been closed by the user before finalizing the operation"
}Handling callback
In local route /callback/naver (the chosen callbackUrl during login())
handleTokenResponse(): void
naver.handleTokenResponse()Get Profile
getProfile(accessToken?: string): Promise\<Profile>
If naver.login() has successfully been called, the accessToken is stored and the accessToken can be omitted.
const profile = await naver.getProfile()However, if you want to get profiles from different logged in users you can override the stored accessToken.
const profile1 = await naver.getProfile(ACCESS_TOKEN1)
const profile2 = await naver.getProfile(ACCESS_TOKEN2)Profile response object
{
message: string // e.g. "success"
response?: {
age?: string // e.g. "30-39"
birthday?: string // e.g. "12-24"
email?: string
id: string
gender?: 'F' | 'M' | 'U'
name?: string
nickname?: string
profile_image?: string
}
resultcode: string // e.g. "00"
}2.0.0
6 years ago
1.2.3
7 years ago
1.2.2
7 years ago
1.2.1
7 years ago
1.2.0
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.11
8 years ago
1.0.10
8 years ago
1.0.9
8 years ago
1.0.8
8 years ago
1.0.7
8 years ago
1.0.6
8 years ago
1.0.5
8 years ago
1.0.4
8 years ago
1.0.3
8 years ago
1.0.2
8 years ago
1.0.1
8 years ago
1.0.0
8 years ago