Skip to content
/ auth Public

Client-side JWT auth using local storage and Auth0 OAuth2 flow.

Notifications You must be signed in to change notification settings

tnguyen14/auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auth

Helper functions to work with Auth0

Usage

SPA

import createAuth from "@tridnguyen/auth/spa";

const auth0 = await createAuth({
  clientId
  authorizationParams: {
    redirect_uri: window.location.href,
    audience: 'https://lists.cloud.tridnguyen.com',
    scope: 'openid profile email'
  }
});

await auth0.getTokenSilently({
  authorizationParams: {
    audience: 'https://lists.cloud.tridnguyen.com',
    scope: 'read:list write:list'
  }
});

await auth0.logout({
  logoutParams: {
    returnTo: window.location.href
  }
})

Machine to machine

import { getToken } from "@tridnguyen/auth/server";

const token = await getToken({
  clientId,
  clientSecret,
  audience
})

About

Client-side JWT auth using local storage and Auth0 OAuth2 flow.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published