@digituz/auth0-web
v2.1.1
Published
[![Auth0 Web build status][travis-image]][travis-url] [![Code Coverage][codecov-image]][codecov-url] [![License][license-image]][license-url] [![NPM version][npm-image]][npm-url]
Downloads
9
Readme
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:
- Install the dependency:
npm i auth0-web
- Import it on some component:
import * as Auth0 from 'auth0-web';
- 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'
});
- 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.