Auth0 Single Page Application SDK
You have a few options for using auth0-spa-js in your project:
From the CDN:
Create the client
First, you'll need to create a new instance of
Auth0Client client object. Create the
Auth0Client instance before rendering or initializing your application. You should only have one instance of the client.
Login and Get User Info
Next, create a button users can click to start logging in.
Listen for click events on the button you created. When the event occurs, use the desired login method to authenticate the user (
loginWithPopup() in this example. After the user is authenticated, you can retrieve the user profile with the
Call an API
To call your API, start by getting the user's Access Token. Then use the Access Token in your request. In this example the
getTokenSilently method is used to retrieve the Access Token.
Finally, add a button users can click to logout.
jQuery is used in the following examples.