v3.0.0
The simplest all-in-one authentication library for JavaScript.
Repository
Current version released
11 months ago
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.
Initialize client.
const github = new GitHub({ clientId: '...', clientSecret: '...', scopes: [ 'read:user', 'user:email' ] // optional })
Create a authorization url.
const url = github.createAuthorizeUri({ state: '...', allowSignup: true })
Retrieve an access token.
const { accessToken } = await github.getToken({ code: '...', redirectUri: 'https://example.com/oauth2/callback' })
Retrieve the user.
const user = await github.getUser(accessToken) , normalizedUser = github.normalizeUser(user)