AWS Cognito

Retrieve an accessToken from AWS Cognito

Overview

This node retrieves an access token from AWS Cognito by authenticating a user with their username and password. It is useful in scenarios where you need to programmatically obtain a valid JWT access token for accessing AWS Cognito-protected resources or APIs. For example, it can be used in workflows that require user authentication before performing further actions, such as calling secured AWS services or custom backend APIs that rely on Cognito tokens.

Properties

Name Meaning
Username The username of the Cognito user to authenticate.
Password The password of the Cognito user (input is masked).

Output

The node outputs a JSON object containing the following field:

  • accessToken: A string representing the JWT access token obtained after successful authentication with AWS Cognito. This token can be used for subsequent authenticated requests.

No binary data output is produced by this node.

Dependencies

  • Requires AWS Cognito User Pool credentials including User Pool ID and Client ID.
  • Uses the amazon-cognito-identity-js library to handle authentication.
  • Requires configuration of an API key credential for AWS Cognito in n8n with the necessary identifiers.
  • No additional environment variables are explicitly required beyond the configured credentials.

Troubleshooting

  • No credentials returned!: This error occurs if the node cannot retrieve the configured AWS Cognito credentials. Ensure that the credentials are properly set up and linked to the node.
  • Authentication failure: If the username or password is incorrect, the authentication will fail. Verify the input values and ensure the user exists in the specified Cognito User Pool.
  • Network or service errors: Connectivity issues or misconfigured User Pool/Client IDs may cause failures. Double-check the credential details and network access.
  • Token retrieval issues: If the node does not return an access token, confirm that the user has permissions and that the User Pool client allows the requested authentication flow.

Links and References

Discussion