How to use auth0-js - 10 common examples

To help you get started, we’ve selected a few auth0-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netlify-labs / movie-app / src / utils / authInstance.js View on Github external
export default function WebAuth() {
  // set xsrf token
  const token = initializeXsrfToken() // eslint-disable-line

  return new auth0.WebAuth({
    domain: config.auth0.domain,
    clientID: config.auth0.clientId,
    audience: `universe-theater`,
    responseType: 'token id_token',
    scope: 'openid email profile'
  })
}
github patrickmichalina / fusing-angular-v1-archived / src / server / services / user.service.ts View on Github external
import { Inject, Service } from 'typedi'
import { Authentication, Management } from 'auth0-js'
import {
  AUTH0_CERT,
  AUTH0_MANAGEMENT_CLIENT_CONFIG,
  Auth0Cert,
  Auth0Config
} from '../rest-api'
import { Observable, Observer, of } from 'rxjs'
import { flatMap, map } from 'rxjs/operators'
import { verify } from 'jsonwebtoken'

@Service()
export class UserService {
  private readonly client = new Authentication(this.config)
  // tslint:disable-next-line:readonly-keyword
  private token: string

  constructor(
    @Inject(type => AUTH0_MANAGEMENT_CLIENT_CONFIG)
    private config: Auth0Config,
    @Inject(type => AUTH0_CERT)
    private cert: Auth0Cert
  ) {}

  fetchAccessToken(auth0: Authentication): Observable {
    return Observable.create((obs: Observer) => {
      auth0.oauthToken(
        {
          grantType: 'client_credentials',
          audience: `https://${process.env.AUTH0_DOMAIN}/api/v2/`,
github auth0 / lock-passwordless / src / index.js View on Github external
Auth0LockPasswordless.plugins = new PluginManager(Auth0LockPasswordless.prototype);
Auth0LockPasswordless.renderer = new Renderer();
Auth0LockPasswordless.renderScheduler = new RenderScheduler(Auth0LockPasswordless);

Auth0LockPasswordless.plugins.register(emailcodeSpec);
Auth0LockPasswordless.plugins.register(magiclinkSpec);
Auth0LockPasswordless.plugins.register(smsSpec);
Auth0LockPasswordless.plugins.register(socialSpec);
Auth0LockPasswordless.plugins.register(socialOrEmailcodeSpec);
Auth0LockPasswordless.plugins.register(socialOrMagiclinkSpec);
Auth0LockPasswordless.plugins.register(socialOrSmsSpec);


// telemetry
Auth0LockPasswordless.version = __VERSION__;
Auth0.clientInfo.lib_version = Auth0.clientInfo.version;
Auth0.clientInfo.name =  "lock-passwordless.js";
Auth0.clientInfo.version = Auth0LockPasswordless.version;
github auth0 / lock-passwordless / src / index.js View on Github external
Auth0LockPasswordless.renderScheduler = new RenderScheduler(Auth0LockPasswordless);

Auth0LockPasswordless.plugins.register(emailcodeSpec);
Auth0LockPasswordless.plugins.register(magiclinkSpec);
Auth0LockPasswordless.plugins.register(smsSpec);
Auth0LockPasswordless.plugins.register(socialSpec);
Auth0LockPasswordless.plugins.register(socialOrEmailcodeSpec);
Auth0LockPasswordless.plugins.register(socialOrMagiclinkSpec);
Auth0LockPasswordless.plugins.register(socialOrSmsSpec);


// telemetry
Auth0LockPasswordless.version = __VERSION__;
Auth0.clientInfo.lib_version = Auth0.clientInfo.version;
Auth0.clientInfo.name =  "lock-passwordless.js";
Auth0.clientInfo.version = Auth0LockPasswordless.version;
github auth0 / lock-passwordless / src / index.js View on Github external
Auth0LockPasswordless.renderer = new Renderer();
Auth0LockPasswordless.renderScheduler = new RenderScheduler(Auth0LockPasswordless);

Auth0LockPasswordless.plugins.register(emailcodeSpec);
Auth0LockPasswordless.plugins.register(magiclinkSpec);
Auth0LockPasswordless.plugins.register(smsSpec);
Auth0LockPasswordless.plugins.register(socialSpec);
Auth0LockPasswordless.plugins.register(socialOrEmailcodeSpec);
Auth0LockPasswordless.plugins.register(socialOrMagiclinkSpec);
Auth0LockPasswordless.plugins.register(socialOrSmsSpec);


// telemetry
Auth0LockPasswordless.version = __VERSION__;
Auth0.clientInfo.lib_version = Auth0.clientInfo.version;
Auth0.clientInfo.name =  "lock-passwordless.js";
Auth0.clientInfo.version = Auth0LockPasswordless.version;
github auth0 / lock-passwordless / src / lock / web_api.js View on Github external
setupClient(lockID, clientID, domain) {
    // TODO: reuse clients
    this.clients[lockID] = new Auth0({
      clientID: clientID,
      domain: domain,
      sendSDKClientInfo: true
    });
  }
github Dramloc / preact-auth0-template / template / src / lib / auth / index.js View on Github external
import { route } from 'preact-router';
import WebAuth from 'auth0-js/src/web-auth';

const auth = new WebAuth({
	domain: process.env.AUTH0_DOMAIN,
	clientID: process.env.AUTH0_CLIENT_ID,
	redirectUri: process.env.REDIRECT_URI,
	audience: `https://${process.env.AUTH0_DOMAIN}/userinfo`,
	responseType: 'token id_token',
	scope: 'openid profile' // only use `openid` if you don't need user profile
});

function login() {
	auth.authorize();
}

function handleAuthentication() {
	auth.parseHash((err, authResult) => {
		if (err) {
			route('/', true);
github rrecuero / fstack-ethdapp-template / client / src / auth / Auth.js View on Github external
constructor(history) {
    console.log('PROCESS.ENV', process.env);
    this.auth0 = new auth0.WebAuth({
      domain: process.env.REACT_APP_AUTH0_DOMAIN,
      clientID: process.env.REACT_APP_AUTH0_CLIENTID,
      audience: process.env.REACT_APP_AUTH0_AUDIENCE,
      redirectUri: REDIRECT_URI,
      responseType: 'token id_token',
      scope: this.requestedScopes
    });
    this.history = history;
    this.login = this.login.bind(this);
    this.logout = this.logout.bind(this);
    this.getProfile = this.getProfile.bind(this);
    this.handleAuthentication = this.handleAuthentication.bind(this);
    this.isAuthenticated = this.isAuthenticated.bind(this);
    this.scheduleRenewal();
 }
github auth0-blog / vuejs2-authentication-tutorial / utils / auth.js View on Github external
import decode from 'jwt-decode';
import axios from 'axios';
import Router from 'vue-router';
import auth0 from 'auth0-js';
const ID_TOKEN_KEY = 'id_token';
const ACCESS_TOKEN_KEY = 'access_token';

const CLIENT_ID = '{AUTH0_CLIENT_ID}';
const CLIENT_DOMAIN = '{AUTH0_DOMAIN}';
const REDIRECT = 'YOUR_CALLBACK_URL';
const SCOPE = '{SCOPE}';
const AUDIENCE = 'AUDIENCE_ATTRIBUTE';


var auth = new auth0.WebAuth({
  clientID: CLIENT_ID,
  domain: CLIENT_DOMAIN
});

export function login() {
  auth.authorize({
    responseType: 'token id_token',
    redirectUri: REDIRECT,
    audience: AUDIENCE,
    scope: SCOPE
  });
}

var router = new Router({
   mode: 'history',
});
github Edgeryders-Participio / realities / ui / src / services / auth / auth.js View on Github external
import Auth0 from 'auth0-js';
import store from 'store';
import history from '@/services/history';

const auth0 = new Auth0.WebAuth({
  domain: process.env.REACT_APP_AUTH0_DOMAIN,
  clientID: process.env.REACT_APP_AUTH0_CLIENT_ID,
  audience: process.env.REACT_APP_AUTH0_AUDIENCE,
  redirectUri: process.env.REACT_APP_AUTH0_CALLBACK_URL,
  responseType: 'token id_token',
  scope: 'openid email',
});

let handlers = [];

function fireHandlers() {
  handlers.forEach(fn => fn());
}

export default {
  login: () => {

auth0-js

Auth0 headless browser sdk

MIT
Latest version published 1 month ago

Package Health Score

86 / 100
Full package analysis