Using Auth0 in your applications means that you will be "outsourcing" the authentication process to a centralized login page in the same way that Gmail, YouTube, and any other Google property redirects to accounts.google.com whenever a user signs in.
Your user will authenticate, and Auth0 will generate an ID Token and Access Token that will be passed back to your application. The Access Token can then be used to call your API and extract attributes for that user (such as name, email, role, or a custom attribute)
When your app needs to fetch user data from your API:
- If the user is not already authenticated, our SDK redirects the user to your Auth0 Authorization Server.
- The user authenticates with Auth0 using one of your configured login options (e.g., username/password, social identity provider, SAML).
- Your app requests an ID Token, Access Token, and Refresh Token.
- Auth0 responds with the requested tokens.
- The Access Token can be used to call your API and retrieve requested data.
For server-side web apps, Auth0 uses the Authorization Code Flow.
Configure your APIOnce you have created your API, you will need to configure any scopes that applications can request during authorization.
Get an Access Token
Your app requests an Access Token (and optionally, a Refresh Token) from your Auth0 Authorization Server using the Authorization Code Flow
Call your APIWhen your app calls your API, it includes the retrieved Access Token in the HTTP Authorization header.
Refresh your Access TokenWhen the Access Token expires you can use the Refresh Token to get a new one from your Auth0 Authorization Server.
The easiest way to implement the Authorization Code Flow is to follow our Regular Web App Quickstarts.
Or, to use our API endpoints, you can follow our tutorial: Call Your API Using the Authorization Code Flow.
Step-by-step instructions for tasks
API endpoints, libraries, and best practices
Understand the fundamentals
- Auth0 offers many ways to personalize your user's login experience and customize tokens using rules and hooks.
- If you are building your own API and you want to secure the endpoints using Auth0, see Protect Your API.
- If you need to add login to your own regular web app, learn how at: Add Login to Your Regular Web App.