0.4.0 • Published 3 years ago

@openauth/github v0.4.0

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

Open Auth - Github

@openauth/github is an implementation of Github OAuth.

Installation

npm i @openauth/github

Usage

import { GithubOAuth } from '@openauth/github'

const oauth = new GithubOAuth({
  clientId: 'client_id',
  clientSecret: 'client_secret',
  redirectUri: 'https://wani.kr/auth/github/callback',
  scope: [
    'read:user',
    'user:email',
    'user:follow',
  ],
})

// 1. After getting auth request uri, connect.
const redirectUri = await oauth.getAuthRequestUri()

// 2. It redirects with the code, and replaces the access token with this code value.
const { accessToken } = await oauth.getAccessTokenResponse(code)

// 3. Get user profile.
await oauth.getAuthUser(accessToken)

// 4. Other API
await oauth.getClient(accessToken).get('user')