OAuth2 Token icon

OAuth2 Token

Retrieves a valid OAuth2 access token from credentials

OAuth2 Token

AI-generated

Overview

This node retrieves a valid OAuth2 access token from the configured credentials. It is useful in workflows where you need to obtain and use an OAuth2 access token for authentication with APIs. The node can optionally perform a minimal dummy API request to trigger a token refresh before retrieving the token, ensuring the token is up-to-date. For example, it can be used to fetch an access token for subsequent API calls in a workflow that integrates with OAuth2-secured services.

Use Case Examples

  1. Use this node to get an OAuth2 access token from a generic OAuth2 API credential before making API requests in the workflow.
  2. Trigger a token refresh by specifying a dummy request URL, then retrieve the refreshed access token for use in subsequent nodes.

Properties

Name Meaning
Authentication The authentication method to use, currently supports 'Generic OAuth2 API'.
Access Token Field Name The name of the field where the retrieved access token will be added in the output JSON.
Dummy Request URL (Optional) An optional URL for a minimal API call to trigger token refresh check. If left blank, the node tries to use the Token URL from the credentials.

Output

JSON

- The retrieved OAuth2 access token added to each output item under the specified field name.

Dependencies

  • Requires OAuth2 API credentials configured in n8n for authentication.

Troubleshooting

  • If no dummy URL is provided and the token URL is missing in credentials, the token refresh check might not be triggered reliably, potentially causing stale tokens.
  • Common errors include failure to retrieve credentials or missing access token in the credentials structure. Verify credential setup and authorization.
  • If the node fails to perform the dummy request, it attempts to retrieve credentials anyway, but errors here indicate issues with OAuth2 credential configuration or network connectivity.

Discussion