0.4.0 • Published 3 years ago

@openauth/facebook v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Open Auth - Facebook

@openauth/facebook is an implementation of Facebook OAuth.

Installation

npm i @openauth/facebook

Usage

import { FacebookOAuth } from '@openauth/facebook'

const oauth = new FacebookOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/facebook/callback',
  scope: [
    'public_profile',
  ],
})

OAuth login link.

oauth.getAuthRequestUri() // print https://www.facebook.com/v7.0/dialog/oauth?response_type=code&client_id=client_id&redirect_uri=https%3A%2F%2Fwani.kr%2Fauth%2Ffacebook%2Fcallback&scope=public_profile

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: 'EAAD...', tokenType: 'bearer', expiresIn: 5165353 }

Save accessToken and use it when requesting API.

const user = await oauth.getAuthUser(response.accessToken)
console.log(user) // { id: '3000000', name: 'Cris Jun' }
0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.1.0

4 years ago

0.2.0

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago