{https://yourApp/callback}
.Parameter Name | Description |
---|---|
response_type | Denotes the kind of credential that Auth0 will return (code or token ). For this flow, the value must be code . |
client_id | Your application’s Client ID. You can find this value in your Application Settings. |
redirect_uri | The URL to which Auth0 will redirect the browser after authorization has been granted by the user. The Authorization Code will be available in the code URL parameter. You must specify this URL as a valid callback URL in your Application Settings. Warning: Per the OAuth 2.0 Specification, Auth0 removes everything after the hash and does not honor any fragments. |
scope | Specifies the scopes for which you want to request authorization, which dictate which claims (or user attributes) you want returned. These must be separated by a space. You can request any of the standard OpenID Connect (OIDC) scopes about users, such as profile or email , custom claims conforming to a namespaced format, or any scopes supported by the target API (e.g., read:contacts ). Include offline_access to get a refresh token (make sure that the Allow Offline Access field is enabled in the Application Settings). |
audience | The unique identifier of the API your web app wants to access. Use the Identifier value on the Settings tab for the API you created as part of the prerequisites for this tutorial. |
state | (recommended) An opaque arbitrary alphanumeric string your app adds to the initial request that Auth0 includes when redirecting back to your application. To see how to use this value to prevent cross-site request forgery (CSRF) attacks, see Mitigate CSRF Attacks With State Parameters. |
organization | (optional) ID of the organization to use when authenticating a user. When not provided, if your application is configured to Display Organization Prompt, the user will be able to enter the organization name when authenticating. |
invitation | (optional) Ticket ID of the organization invitation. When inviting a member to an Organization, your application should handle invitation acceptance by forwarding the invitation and organization key-value pairs when the user accepts the invitation. |
HTTP 302
response. The authorization code is included at the end of the URL:
code
) from the previous step, you will need to POST
to the token URL.
Parameter Name | Description |
---|---|
grant_type | Set this to authorization_code . |
code | The authorization_code retrieved in the previous step of this tutorial. |
client_id | Your application’s Client ID. You can find this value in your Application Settings. |
client_secret | Your application’s Client Secret. You can find this value in your Application Settings. To learn more about available application authentication methods, read Application Credentials. |
redirect_uri | The valid callback URL set in your Application settings. This must exactly match the redirect_uri passed to the authorization URL in the previous step of this tutorial. Note that this must be URL encoded. |
HTTP 200
response with a payload containing access_token
, refresh_token
, id_token
, and token_type
values:
refresh_token
will only be present in the response if you included the offline_access
scope and enabled Allow Offline Access for your API in the Dashboard.
Refresh tokens must be stored securely since they allow a user to remain authenticated essentially forever.
3
Make an API call
To call your API from a regular web application, the application must pass the retrieved access token as a Bearer token in the Authorization header of your HTTP request.
offline_access
scope when you initiated the authentication request through the authorize endpoint.POST
request to the /oauth/token
endpoint in the Authentication API, using grant_type=refresh_token
.
Parameter Name | Description |
---|---|
grant_type | Set this to refresh_token . |
client_id | Your application’s Client ID. You can find this value in your Application Settings. |
refresh_token | The refresh token to use. |
scope | (optional) A space-delimited list of requested scope permissions. If not sent, the original scopes will be used; otherwise you can request a reduced set of scopes. Note that this must be URL encoded. |
HTTP 200
response with a payload containing a new access_token
, its lifetime in seconds (expires_in
), granted scope
values, and token_type
. If the scope of the initial token included openid
, then the response will also include a new id_token
: