Token Vault is currently available in Early Access for public cloud tenants. To enable Token Vault, contact your Auth0 representative.
Prerequisites
Before getting started, you must configure Token Vault.Get access to third-party API
To schedule the meeting, the productivity app needs the user’s permission to access the Google Calendar API. When the user logs into a new Google social connection:- Similar to a regular social login flow, the Auth0 SDK makes a
GET
request to the/authorize
endpoint with the following additional parameters:
Parameter | Description |
---|---|
connection | The name of a social identity provider. In this case, google-oauth2 . |
connection_scope | Requests additional scopes to be authorized for the connection. In this case, it includes the Google Calendar API scopes. Note: At runtime, the list of connection scopes is merged with the scopes you statically configured for the connection. Whenever the user is redirected to authorize this connection, Auth0 will always request the scopes you selected. To learn more, read Configure Token Vault. |
scope | Requests Auth0 scopes to be authorized for the application. Include offline_access to get an Auth0 refresh token from the Auth0 Authorization Server. |
- The Auth0 redirects the user to the consent prompt for the Google connection. The user authenticates using one of the configured login options and authorizes the Google connection, giving the application permission to access the Google Calendar API.
- The Auth0 Authorization Server redirects the user back to the application with the single-use authorization code.
-
The Auth0 SDK makes a POST request to the
/oauth/token
endpoint with the authorization code, application’s , and application’s credentials, such as or Private Key . - The Auth0 Authorization Server verifies the request and responds with an Auth0 access token, refresh token, and . The application can use the ID token containing the user’s profile information to link user accounts. To learn more, read User account linking.
- The Auth0 Authorization Server stores the Google access and refresh tokens in a secure tokenset within the user’s Token Vault.
Call third-party API
To schedule the meeting, the application needs to call the Google Calendar API. The application can use a valid Auth0 refresh token to request a Google access token with the scopes granted in the login flow without the user having to re-authorize the connection. To learn more, read Manage federated refresh tokens. To call the Google Calendar API:- The application calls Auth0 SDKs to make a request to the
/oauth/token
endpoint with the following parameters:
Parameter | Description |
---|---|
grant_type | The grant type. For Token Vault, set to urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token |
client_id | Client application ID |
client_secret | Client secret. Note: You can use any client authentication method to get a federated access token. |
subject_token_type | Type of subject token. For Token Vault, set to refresh token: urn:ietf:params:oauth:token-type:refresh_token |
subject_token | The Auth0 refresh token that the Auth0 Authorization Server validates to identify the user. |
requested_token_type | The requested token type. For Token Vault, set to federated access token or http://auth0.com/oauth/token-type/federated-connection-access-token |
connection | The connection name, in this case, google-oauth2 . |
login_hint | (Optional) The user ID for the identity provider. Only use login_hint if the user has several accounts from the same connection. For instance, a user may connect their work and personal Google account. |
- Auth0 checks if the user profile’s
identities
array contains a user account with the connection name passed in the authorization request. - If the authorization request contains
login_hint
, Auth0 looks for an identity matching both the connection name and thelogin_hint
. - If Auth0 can’t find the user, it returns a
401
status code with an error message.