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

0.4.0 • Public • Published

Open Auth - Github

Downloads Version License Typescript dependencies Status

@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')

Package Sidebar

Install

npm i @openauth/github

Weekly Downloads

0

Version

0.4.0

License

MIT

Unpacked Size

12.9 kB

Total Files

15

Last publish

Collaborators

  • wan2land