Authorization Code Grant
Description
The Authorization Code Grant connection type (authorization-code-grant) connects to an API using OAuth 2.0 authorization granted by a user. The Connections list filter shows this type as OAuth2 app.
The connection references an AuthZ Code App configured in Contextual. This app defines the provider’s authorization and token endpoints, client credentials, and the API endpoint used by the connection.
Creating the connection does not authorize it. You must also sign in to the provider and grant access through the app’s Registration tab. Contextual then stores the tokens and refreshes the access token when it expires.
Before You Begin
An AuthZ Code App must be configured under Admin → AuthZ Code Apps. Its connection configuration must specify the API Endpoint that requests will use.
The provider must also have the app’s Redirect URI registered. You can find this URI on the app’s Registration tab.
Configure your OAuth provider to issue a refresh token for this app. Contextual uses it to renew access when the access token expires.
Required Information
After you select this type in Connection Type, the console asks for the following fields. Every connection also has a Connection ID, Connection Name, and Connection Type.
| Field | Required | Description |
|---|---|---|
| App ID | Yes | The ID of the AuthZ Code App record in Contextual. This is different from the provider’s OAuth Client ID. |
| Scope | No | The access scopes to request from the provider. |
Usage
- Under Connect → Connections, select New connection → General connection. Set Connection Type to
authorization-code-grant. - Enter the Connection ID, Connection Name, and App ID. Enter any required Scope values, then select Create.
- Under Admin → AuthZ Code Apps, open the app referenced by App ID and select its Registration tab.
- Under Provider Connections, find the connection you created and select Connect.
- Sign in to the provider and grant the requested access. After returning to Contextual, confirm that the connection shows Connected.
- In a Flow, select the authorized connection in a Contextual HTTP node’s Connection field. Requests use the connection’s saved API endpoint and include the OAuth access token.
- If the API requires additional request headers, configure them in the HTTP node’s Headers settings.
If you change the AuthZ Code App’s API Endpoint, open its Registration tab. Under Provider Connections, select Disconnect, then Connect for each affected connection, and complete the provider authorization again.
Requests using the connection can fail while it is disconnected.