2.1.1 • Published 6 years ago

@digituz/auth0-web v2.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Auth0 Web build status Code Coverage License NPM version

Auth0 Web

This is a wrapper around Auth0.js that favors convention over configuration. Using it on frameworks like Angular and React is quite easy. To use it, we basically have to do four things:

  1. Install the dependency:
npm i auth0-web
  1. Import it on some component:
import * as Auth0 from 'auth0-web';
  1. Configure it with our Auth0 properties:
Auth0.configure({
  domain: 'bk-samples.auth0.com',
  audience: 'https://contacts.digituz.com.br',
  clientID: '8a7myyLd6leG0HbOhMPtLaSgZ2itD3gK',
  redirectUri: 'http://localhost:3000/callback',
  responseType: 'token id_token',
  scope: 'openid get:contacts post:contacts delete:contacts'
});
  1. Use the API:
// triggers the authentication process
Auth0.signIn();

// handle authentication callback
Auth0.handleAuthCallback();

// get user profile
Auth0.getProfile();

By default, this library uses the Implicit Grant flow of OAuth 2.0. However, developers looking forward to use the Authorization Code Grant flow can still use this library by passing oauthFlow: AUTHORIZATION_CODE, alongside with the other properties, to Auth0Web.configure().

Development Tips

You can use the npm-link feature to test new versions of this package locally. After configuring it, you will have to update the dist package with the new code. This can be done as shown here:

tsc -p ./ --outDir dist/

License

This project is licensed under the MIT license. See the LICENSE file for more info.