OAuth2 Keys
An OAuth2 key is the portal's record of an OAuth2 client on a key manager. It holds the consumer key and the details needed to request access tokens. OAuth2 keys are listed under Keys › OAuth2 Keys.
An OAuth2 key belongs to the user who creates it, not to an application. To generate a key and invoke an API, see Consume an OAuth2-Secured API.
Ways to Get a Key
The buttons on the OAuth2 Keys page depend on how the key managers of your organization are configured.
| Option | What Happens | Available When |
|---|---|---|
| Register OAuth2 client | The portal registers a new OAuth2 client on the key manager, and returns its consumer key and secret. | The key manager lets the portal create applications, as ThunderID does by default. |
| Import OAuth2 client | You create the OAuth2 application in the key manager, and import its client ID into the portal. | The portal shows this button only when a key manager that supports import exists. See Configure a Custom Key Manager. |
Key Details
When you generate a key, you can set the following details.
| Field | Description |
|---|---|
| Key manager | Required. The key manager that registers the application. |
| Application name | Required. The name of the application, which end users see on the consent screen. |
| Callback URLs | Where the key manager sends the user after login. Enter absolute URIs, without a fragment. Required only for the authorization code grant. |
| Grant types | Required. The OAuth2 grants that the application can use: Authorization code, Refresh token, or Client credentials. |
| Response types | The response types of the authorization endpoint: code, token, or id_token. They must match the selected grant types. |
| Client authentication method | How the application authenticates at the token endpoint. |
Import an existing client
-
Go to Keys › OAuth2 Keys, and click Import OAuth2 client. The Import an existing client dialog opens.
-
Select the Key manager, and enter the client ID of the OAuth2 application that you created in the key manager.
-
Click Import client.
The portal does not register anything on the key manager for an existing key. It only records the client ID, so that it can request tokens with it. Keep the client secret from where you created the application.
Get a Token with curl
You can request a token directly from the token endpoint of the key manager. Use this option in scripts, such as in continuous integration (CI), because it does not involve the portal.
curl -X POST "<token-endpoint>" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-u "<client-id>:<client-secret>"
The response contains the access token.
{
"access_token": "eyJhbGciOiJSUzI1NiJ9...",
"token_type": "Bearer",
"expires_in": 3600
}
To request scopes, add -d "scope=<scopes>". If the key manager requires a resource indicator, add -d "resource=<resource>".
Production and Sandbox Keys
Each key is either a production key or a sandbox key, based on the key manager that it is created on. The list shows a Sandbox badge on sandbox keys. Sandbox tokens are for testing, and do not work with production endpoints.
Associate a Key with an Application
This step is optional. Associate a key with an application to track its usage in analytics. It is not required to invoke an API.
-
From the key: In the Application column of the key, click the + button (Associate an application) or the pencil button (Change application). In the Associate with an application dialog, select the application, and click Save. The dialog lists applications that already hold a key of that type, but you can't select them.
-
From the application: Open the application, and in the OAuth2 keys section, click Associate existing OAuth2 key.
The following rules apply.
-
A key belongs to at most one application. Associating it with another application moves it there.
-
An application holds at most one key of each key type: one production key and one sandbox key. If the application already has a key of the same type, the association is refused with a
409 Conflicterror. Remove the association of the existing key first. -
Associating a key with the application that it already belongs to succeeds, and leaves the association unchanged.
-
Removing the association, or deleting the application, leaves the key usable and unassociated.
See Manage Applications.
Edit or Delete a Key
-
Edit: In the Actions menu of the key, click Update. In the Update OAuth2 key dialog, change the details that the key manager holds, such as the name or callback URLs, and click Save changes. For a key that the portal registered, the portal also sends the change to the key manager.
-
Delete: In the Actions menu of the key, click Delete. In the Delete OAuth2 key confirmation, click Delete key. For a key that the portal registered, this also deletes the OAuth2 application on the key manager. For an existing key that you added, only the record in the portal is deleted.
Deleting a key does not invalidate the tokens that were issued with it. They stay valid until they expire. To revoke a live token, use the revocation endpoint of the key manager.
Next Steps
- Consume an OAuth2-Secured API - Generate a key and a token, and invoke the API
- Key Managers - Learn how key managers issue tokens
Was this page helpful?