@auth0/auth0-login
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-alpha.15 • Public • Published

CircleCI

Auth0Login

Goal

This library implements a simple, lightweight and opinionated client for Code+PKCE. It's a work in progress.

To simplify the usage of the OAuth 2.0 Implicit Flow, the library will:

  • Get a new access_token when requested using response_mode=web_message (you can use custom audiences and scopes)
  • Hide the response_type parameter.
  • Always force scope = openid profile email, allowing users to add more scopes if needed.
  • Automatically manage state

cdn link

https://unpkg.com/@auth0/auth0-login/dist/auth0-login.production.js

$(async () => {
  var auth0 = new Auth0Login({
    domain: 'auth.brucke.club',
    client_id: 'wLSIP47wM39wKdDmOj6Zb5eSEw3JVhVp'
  });
  try {
    await auth0.init();
  } catch (error) {
    console.log(error);
  }

  $('#login_redirect').click(async () => {
    await auth0.loginWithRedirect({
      redirect_uri: 'http://localhost:3000/'
    });
  });
  $('#login_popup').click(async () => {
    await auth0.loginWithPopup();
  });
  $('#login_redirect_callback').click(async () => {
    await auth0.handleRedirectCallback();
  });
  $('#getToken').click(async () => {
    const token = await auth0.getTokenSilently();
    console.log(token);
  });
  $('#getTokenPopup').click(async () => {
    const token = await auth0.getTokenWithPopup({
      audience: 'https://brucke.auth0.com/api/v2/',
      scope: 'read:rules'
    });
    console.log(token);
  });
  $('#getUser').click(async () => {
    const user = await auth0.getUser();
    console.log(user);
  });
  $('#getToken_audience').click(async () => {
    const differentAudienceOptions = {
      audience: 'https://brucke.auth0.com/api/v2/',
      scope: 'read:rules'
    };
    const token = await auth0.getTokenSilently(differentAudienceOptions);
  });
  $('#logout').click(async () => {
    auth0.logout({
      client_id: 'wLSIP47wM39wKdDmOj6Zb5eSEw3JVhVp',
      returnTo: 'http://localhost:3000/'
    });
  });
});

running the project

yarn install
yarn dev

/@auth0/auth0-login/

    Package Sidebar

    Install

    npm i @auth0/auth0-login

    Weekly Downloads

    1

    Version

    0.0.1-alpha.15

    License

    MIT

    Unpacked Size

    2.04 MB

    Total Files

    31

    Last publish

    Collaborators

    • jfromaniello
    • edgarchirivella-okta
    • sanjay.manikandhan
    • ncluer
    • vic-dev
    • enriquepina
    • ece-okta
    • pubalokta
    • dougmiller-okta
    • zak.nour
    • stheller
    • jamescgarrett-okta
    • madhuri.rm23
    • willvedd
    • david.renaud.okta
    • jeff.shuman
    • auth0-oss
    • codepete
    • ziluvatar
    • iaco
    • cocojoe
    • auth0npm
    • auth0brokkr
    • hzalaz
    • aaguiarz
    • charlesrea
    • lbalmaceda
    • julien.wollscheid
    • cristiandouce
    • sambego
    • stevehobbsdev
    • sandrinodimattia
    • lzychowski
    • joshcanhelp
    • davidpatrick0
    • widcket
    • adamjmcgrath
    • jim.andersoon
    • frederikprijck
    • sergii.biienko
    • tomauth0
    • jpadilla
    • jessele
    • rhamzeh_auth0