Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback

authenticus

Setup

Deno

import { GitHub } from 'https://esm.sh/authenticus'

Node.js

npm i authenticus
import { GitHub } from 'authenticus'

Presets

Usage

Important

You should wrap your code within a try…catch block, as each of the methods listed below can cause an AuthenticusError in some rare cases.

  1. Initialize client.

    const github = new GitHub({
      clientId: '...',
      clientSecret: '...',
      scopes: [
        'read:user',
        'user:email'
      ] // optional
    })
  2. Create a authorization url.

    const url = github.createAuthorizeUri({
      state: '...',
      allowSignup: true
    })
  3. Retrieve an access token.

    const { accessToken } = await github.getToken({
      code: '...',
      redirectUri: 'https://example.com/oauth2/callback'
    })
  4. Retrieve the user.

    const user = await github.getUser(accessToken)
    
    , normalizedUser = github.normalizeUser(user)