Dynamic Credential Provider

Prépare les credentials dynamiques pour être utilisés dans le workflow

Overview

This node, named "Dynamic Credential Provider," is designed to handle dynamic credentials within an n8n workflow. It supports two main operations on credentials: formatting and validating them. The node is particularly useful when working with OAuth2 tokens or API keys that need to be dynamically prepared or checked before use in subsequent workflow steps.

A common scenario for this node is managing Microsoft-related credentials (Microsoft Graph, Microsoft Outlook OAuth2, Microsoft Entra OAuth2) where tokens must be formatted into a consistent structure or validated to ensure required fields like access tokens are present. For example, before making API calls to Microsoft services, you can validate that the credentials are complete and valid, or format raw credential data into a standard shape expected by other nodes.

Properties

Name Meaning
Type de Credential The type of credential to process. Options: Microsoft Graph, Microsoft Outlook OAuth2, Microsoft Entra OAuth2

Output

The output depends on the selected operation:

  • Format Credentials:
    Outputs the original item JSON extended with a _n8n_credentials field containing:

    • id: The original credential ID.
    • name: A generated name combining "Dynamic", the credential type, and the current timestamp.
    • type: The credential type selected.
    • data: An object with standardized token fields such as access_token, expires_in, refresh_token, scope, and token_type. If some fields are missing, defaults are applied (e.g., expires_in defaults to 3600 seconds, token_type defaults to "Bearer").
  • Validate Credentials:
    Outputs the original item JSON extended with a credentialValidation field containing:

    • isValid: Boolean indicating if the credential has all required fields.
    • missingFields: Array listing any missing required fields (for Microsoft credentials, it checks for access_token).
    • credentialType: The type of credential validated.

No binary data output is produced by this node.

Dependencies

  • Requires input items to contain a dynamicCredentials object in their JSON, which holds the credential data under a data property.
  • Works with Microsoft-related OAuth2 credentials but can be extended for other types.
  • No external API calls are made by this node itself; it operates purely on provided credential data.
  • No special environment variables or additional n8n configurations are needed beyond supplying the appropriate credential data in the input.

Troubleshooting

  • Error: "Les credentials dynamiques n'ont pas été trouvés dans l'item X"
    This error occurs if an input item does not have the expected dynamicCredentials property in its JSON. Ensure that previous nodes correctly provide this data.

  • Validation fails (isValid false) with missing fields
    Indicates that required token fields (like access_token) are absent. Check the source of the credentials to confirm they are properly fetched and stored.

  • Unsupported credential type
    If a credential type outside the supported Microsoft options is used, the node will default to passing through the data without formatting or validation. Confirm the credential type matches one of the supported options.

Links and References

Discussion