Troubleshoot Amazon Cognito
This chapter provides solutions to common problems you might encounter while working with Amazon Cognito. Amazon Cognito implementations can face various challenges across authentication flows, user pool configurations, and identity federation setups. Whether you're developing a new application or maintaining an existing one, this troubleshooting guide helps you identify and resolve common issues quickly.
To use this page, find your error message or symptom in the following index and choose the linked section. Each entry describes the problem, its likely causes, and a solution. The entries are grouped by the area of Amazon Cognito where the problem occurs, such as sign-in, tokens, or federation.
Sign-in and authentication
The following errors occur during sign-in and token refresh with Amazon Cognito user pools.
Invalid refresh token error
You receive this error when you exchange a refresh token for new ID and access tokens with the InitiateAuth or AdminInitiateAuth API operation.
- Problem
-
The token refresh request fails with an
Invalid refresh tokenerror. - Cause
-
-
The refresh request uses a different app client ID than the one that generated the refresh token.
-
Device tracking is enabled, but the user's device isn't confirmed, or the request doesn't include the device key.
-
Device tracking is enabled, but the initial authentication didn't use the
USER_SRP_AUTHflow.
-
- Solution
-
Apply the following steps based on your user pool configuration and API usage:
-
Use a consistent app client ID: When you call the
InitiateAuthorAdminInitiateAuthAPI for token refresh, use the exact same app client ID that was used during the initial authentication that generated the refresh token. -
Confirm the device: If you have device tracking enabled on your user pool, but the user's device isn't confirmed, call the ConfirmDevice API first. After the user confirms their device, you can exchange the refresh token.
-
Include the device key in the refresh request: If device tracking is enabled, include the unique device key as an
AuthParameterwhen you use theREFRESH_TOKEN_AUTHflow:{ "AuthFlow": "REFRESH_TOKEN_AUTH", "AuthParameters": { "REFRESH_TOKEN": "example_refresh_token", "SECRET_HASH": "example_secret_hash", "DEVICE_KEY": "example_device_key" } }Include
SECRET_HASHonly if your app client has a client secret. -
Use
USER_SRP_AUTHfor device tracking: If you use device tracking, the initial authentication flow must beUSER_SRP_AUTH.
-
For more information, see Working with user devices in your user pool.
Incorrect username or password.
A sign-in request returns this error when Amazon Cognito can't authenticate the user with the credentials provided.
- Problem
-
The request returns
NotAuthorizedExceptionwith the messageIncorrect username or password. - Cause
-
-
The password is wrong.
-
The user doesn't exist and the app client has Prevent user existence errors enabled. Amazon Cognito returns this same generic message so that it doesn't reveal whether the user exists. The legacy setting instead returns
UserNotFoundExceptionwithUser does not exist. -
The request uses the wrong app client, or it's missing the
SECRET_HASHfor a client that has a client secret. -
The user's status prevents password sign-in.
-
- Solution
-
-
Verify the password and confirm that the request uses the correct app client.
-
Confirm that the user exists and check the user's status with administrative tools.
-
Include a valid
SECRET_HASHif the app client has a client secret.
We recommend that you keep Prevent user existence errors enabled. It protects your user pool against user enumeration. To investigate sign-in failures, use AWS CloudTrail and user pool sign-in activity instead of turning it off.
-
For more information, see Managing error responses.
USER_PASSWORD_AUTH flow not enabled for this client
An authentication request fails because the requested authentication flow isn't enabled on the app client.
- Problem
-
The request returns
InvalidParameterException. The message varies by flow:USER_PASSWORD_AUTH flow not enabled for this clientfor the client-side password flow,Auth flow not enabled for this clientfor admin flows, orUSER_AUTH flow not enabled for this clientfor choice-based authentication. - Cause
-
The authentication flow in the request isn't in the app client's list of allowed authentication flows.
- Solution
-
Enable the matching flow on the app client:
ALLOW_USER_PASSWORD_AUTHforUSER_PASSWORD_AUTH,ALLOW_ADMIN_USER_PASSWORD_AUTHfor admin password authentication, orALLOW_USER_AUTHfor choice-based authentication.Password-based flows send the user's password to Amazon Cognito instead of using Secure Remote Password (SRP). We recommend SRP or choice-based authentication where possible, and that you use
ADMIN_USER_PASSWORD_AUTHonly from server-side code.
For more information, see Authentication with user pools.
User is not confirmed.
A user who signed up but never confirmed their account can't sign in.
- Problem
-
A sign-in request returns
UserNotConfirmedExceptionwith the messageUser is not confirmed. - Cause
-
The user completed sign-up but never confirmed their account, so their status is
UNCONFIRMED. - Solution
-
-
Have the user confirm their account. Call
ResendConfirmationCodeto send a new code, then callConfirmSignUpwith that code. -
An administrator can confirm the user directly with
AdminConfirmSignUp. -
A pre sign-up Lambda trigger can automatically confirm users.
Automatic confirmation skips email and phone number verification. We recommend that you auto-confirm users only for trusted or migration scenarios.
-
For more information, see Pre sign-up Lambda trigger.
NEW_PASSWORD_REQUIRED challenge and FORCE_CHANGE_PASSWORD status
A user that an administrator created with the AdminCreateUser API operation must set a new password the first time they sign in.
- Problem
-
During sign-in, Amazon Cognito returns a
NEW_PASSWORD_REQUIREDchallenge and the user can't complete authentication with only their user name and temporary password. - Cause
-
The user has the
FORCE_CHANGE_PASSWORDstatus because an administrator created them with a temporary password. Amazon Cognito requires a permanent password before it issues tokens. - Solution
-
Respond to the challenge with the RespondToAuthChallenge API operation (or the
AdminRespondToAuthChallengevariant). In your response:-
In
ChallengeResponses, provideNEW_PASSWORDandUSERNAME. IncludeSECRET_HASHif your app client has a client secret. -
Include every attribute that the challenge lists in
requiredAttributes, each asuserAttributes.. If one is missing or empty, the request returnsattribute_nameInvalidParameterExceptionwith the messageInvalid attributes given,.attribute_nameis missing -
You can only set attributes that are mutable and that the app client has write access to.
-
Include the
Sessionvalue from the challenge response. TheSessionfrom the challenge can be used only once and expires. Reusing or sending an expired session returnsNotAuthorizedExceptionwithInvalid session for the user, session can only be used once.orInvalid session for the user, session is expired.Start sign-in again to get a new session.
-
For more information, see Authentication with user pools.
Attempt limit exceeded, please try after some time.
Amazon Cognito temporarily blocks further attempts after repeated failures for a user.
- Problem
-
A request returns
LimitExceededExceptionwith the messageAttempt limit exceeded, please try after some time. - Cause
-
Repeated failed password or verification code attempts for the same user cause Amazon Cognito to temporarily block further attempts. This protection defends against brute-force attacks.
- Solution
-
Wait before you retry, and add exponential backoff to your client. Don't automatically resubmit failed credentials, because repeated attempts extend the block. Ask the user to try again later or to reset their password.
App client secret (SECRET_HASH) errors
App clients that have a client secret require a SECRET_HASH value in authentication API requests. The following errors occur when the secret hash is missing, incorrect, or sent to a client that has no secret.
Your application calculates the SECRET_HASH for the current user, app client, and client secret with the following method:
Base64 ( HMAC_SHA256 ( "Client Secret Key", "Username" + "Client Id" ) )
The Username must be the value sent in the request. For the REFRESH_TOKEN_AUTH flow, when the user name isn't a sign-in attribute, use the user's sub. To get the client secret, you can:
-
Open the Amazon Cognito console and navigate to your app client from the App clients menu. In the App client information section, locate Client secret. Choose Show client secret and your app client secret appears.
-
Generate a DescribeUserPoolClient request. The client secret is included in the response.
Client secrets are for confidential (server-side) clients only. Never put a client secret or the secret hash routine in a browser or mobile app.
Client client-id is configured with secret but SECRET_HASH was not received
client-id is configured with secret but SECRET_HASH was not received- Problem
-
An authentication API request returns
NotAuthorizedExceptionwith a message such asClient.client-idis configured with secret but SECRET_HASH was not received - Cause
-
The app client has a client secret, but the request didn't include a
SECRET_HASH. - Solution
-
Compute the secret hash with the formula in this section and include it in the request.
Unable to verify secret hash for client client-id
client-id- Problem
-
An authentication API request returns
NotAuthorizedExceptionwith the messageUnable to verify secret hash for client.client-id - Cause
-
The
SECRET_HASHvalue is wrong. The calculation used the wrong user name, client ID, or client secret, or the client secret was rotated or deleted. - Solution
-
-
Recompute the secret hash with the exact user name sent in the request, the correct client ID, and the current client secret.
-
For the
REFRESH_TOKEN_AUTHflow, when the user name isn't a sign-in attribute, use the user'ssubas the user name in the calculation. -
If the client secret was rotated or deleted, get the current secret and recalculate.
-
App client client-id is not configured for secret but secret hash was received
client-id is not configured for secret but secret hash was received- Problem
-
An authentication API request returns
InvalidParameterExceptionwith the messageApp client.client-idis not configured for secret but secret hash was received - Cause
-
The request sent a
SECRET_HASHto an app client that doesn't have a client secret. - Solution
-
Remove the
SECRET_HASHparameter from requests to this app client.
For more information, see Computing secret hash values.
OAuth 2.0 and managed login
The following errors come from the Amazon Cognito OAuth 2.0 endpoints that managed login uses.
redirect_mismatch at the authorization endpoint
- Problem
-
The
/oauth2/authorizeendpoint returns an error withredirect_mismatch. - Cause
-
The
redirect_uriin the request doesn't exactly match a callback URL that is registered on the app client. - Solution
-
Register the exact callback URL on the app client and send an identical
redirect_uri. The URI must be absolute and must not include a fragment (#). It must use HTTPS, except that you can usehttp://localhost(and127.0.0.1and[::1]) for testing.
For more information, see Authorize endpoint and Application-specific settings with app clients.
invalid_grant at the token endpoint
- Problem
-
The
/oauth2/tokenendpoint returnsinvalid_grantwhen it exchanges an authorization code or a refresh token. - Cause
-
The authorization code was already redeemed or doesn't exist. Authorization codes are single-use and short-lived. The error also occurs when the refresh token was revoked.
- Solution
-
Exchange each authorization code only once, and guard against a double exchange, such as a component that runs twice or a page refresh that replays the callback. If a refresh token was revoked, have the user sign in again.
For more information, see Token endpoint.
invalid_request with PKCE at the token endpoint
- Problem
-
The
/oauth2/tokenendpoint returnsinvalid_requestwhen your app client uses Proof Key for Code Exchange (PKCE). - Cause
-
The token request is missing the
code_verifier(theerror_descriptionisinvalid_code_verifier), or thecode_verifierdoesn't match thecode_challengethat was sent to/oauth2/authorize. - Solution
-
Send the original
code_verifierthat corresponds to thecode_challengefrom the authorize request, and keep it for the duration of the flow.
For more information, see Token endpoint.
invalid_client and unauthorized_client at the token endpoint
- Problem
-
The
/oauth2/tokenendpoint returnsinvalid_clientorunauthorized_client. - Cause
-
-
invalid_clientmeans client authentication failed. A client that has a secret must authenticate with anAuthorization: Basicheader orclient_secret_post, or the client ID is unknown. -
unauthorized_clientmeans the grant type isn't enabled on the app client. It also occurs when theredirect_urion the token request doesn't match the one used at/oauth2/authorize(theerror_descriptionisinvalid_redirect).
-
- Solution
-
-
For confidential clients, send valid client credentials.
-
Enable the grant type on the app client.
-
Use the same
redirect_uriin the authorize request and the token request.
Public clients don't have a secret. We recommend that public clients use the authorization code grant with PKCE.
-
For more information, see Token endpoint.
CORS error calling the token endpoint from a browser
- Problem
-
Browser calls to the
/oauth2/tokenendpoint fail with a cross-origin resource sharing (CORS) error. - Cause
-
The token endpoint returns
Access-Control-Allow-Origin: *and supports browser calls only for public clients that use the authorization code grant with PKCE. It doesn't support custom CORS origin policies, and confidential clients aren't meant to call it from a browser. - Solution
-
For browser-based apps, use a public client with the authorization code grant and PKCE. For confidential clients, exchange the authorization code for tokens from server-side code.
For more information, see Token endpoint.
Tokens and JWT validation
The following issues occur when your application validates Amazon Cognito tokens or passes them to other services.
JWT signature or claim validation fails
- Problem
-
Your application rejects a valid Amazon Cognito JSON Web Token (JWT), or accepts a token that it shouldn't.
- Cause
-
The token's signature, claims, or type weren't validated correctly.
- Solution
-
-
Verify the signature against the JSON Web Key Set (JWKS) for your user pool, at
https://cognito-idp., and select the key whoseRegion.amazonaws.com/userPoolId/.well-known/jwks.jsonkidmatches the token header. -
Check the
issclaim, theexpclaim, and thetoken_useclaim (idfor ID tokens,accessfor access tokens). -
ID tokens carry
audequal to your app client ID. Access tokens carryclient_id. An access token that is scoped to an API resource also carriesaudwith the resource. -
We recommend the
aws-jwt-verifylibrary. Never trust an unverified JWT.
-
For more information, see Verifying a JSON Web Token.
Access Token does not have required scopes
- Problem
-
A self-service user pool operation such as
GetUser,UpdateUserAttributes, orAssociateSoftwareTokenreturnsNotAuthorizedExceptionwithAccess Token does not have required scopes. - Cause
-
These operations require the
aws.cognito.signin.user.adminscope, which is missing from the access token. Tokens from SDK authentication (InitiateAuth) include this scope. Tokens from managed login include it only if the app client allows the scope and the request asks for it. Client credentials tokens never include it. - Solution
-
Use an access token that carries
aws.cognito.signin.user.admin. Authenticate with the Amazon Cognito API, or request the scope in managed login and allow it on the app client. We recommend that you allow only the scopes each app client needs.
For more information, see Scopes, M2M, and APIs with resource servers.
401 Unauthorized from an API Gateway user pool authorizer
- Problem
-
Requests to an Amazon API Gateway API that uses a Amazon Cognito user pool authorizer return
401 Unauthorized. - Cause
-
-
You sent an ID token when the method has no OAuth scopes configured, or an access token when scopes are configured.
-
The token is expired.
-
The token came from a user pool that doesn't match the authorizer.
-
The token's format or header doesn't match the authorizer's identity source.
-
- Solution
-
Send the token type the method expects, make sure the token hasn't expired, confirm it was issued by the authorizer's user pool, and match the identity source header. For a detailed walkthrough, see How do I troubleshoot HTTP 401 Unauthorized errors from an API Gateway API with a Amazon Cognito user pool authorizer?
in the AWS Knowledge Center on the AWS re:Post website.
For more information, see Understanding user pool JSON web tokens (JWTs).
Multi-factor authentication (MFA)
The following issues affect multi-factor authentication in user pools.
Managed login users can't select an MFA factor
- Problem
-
Users can't choose their preferred MFA method when signing in through managed login, or they aren't prompted for the MFA method you expect.
- Cause
-
Amazon Cognito follows specific logic to determine which MFA factors are available to users, based on user pool settings, user attributes, and account recovery configuration. For example, users can't use email MFA if email is configured as their primary account recovery method.
- Solution
-
To override the default MFA factor selection, you can use either of these approaches:
-
For public applications, use SetUserMFAPreference with a valid access token to let users set their own MFA preferences.
-
For administrator-managed applications, use AdminSetUserMFAPreference with AWS credentials to configure user MFA preferences.
With both operations, you can enable or disable SMS, email, and TOTP MFA methods for individual users, and set one method as preferred.
-
For more information, see Adding MFA to a user pool.
Passwordless and passkey users can't use MFA
- Problem
-
Users who sign in with one-time password (OTP) authentication methods can't add or use multi-factor authentication.
- Cause
-
OTP sign-in flows don't support MFA.
- Solution
-
Passkey authentication with user verification can satisfy MFA requirements. Set
FactorConfigurationtoMULTI_FACTOR_WITH_USER_VERIFICATIONin your user poolWebAuthnConfigurationto allow passkeys to count as multi-factor authentication.
For more information, see Authentication with user pools.
Email and SMS delivery
The following issues affect the email and SMS messages that Amazon Cognito sends, such as verification and account recovery codes.
Not able to receive password reset code through email or SMS
- Problem
-
Users can't receive verification codes during the forgot password workflow through their email or SMS.
- Cause
-
Codes might not be delivered for several reasons, including unverified contact attributes, messaging service limits, sandbox restrictions, or MFA conflicts.
- Solution
-
Follow this checklist to troubleshoot the issue:
-
Check the user's email spam and junk folders.
-
Confirm that the user exists in the user pool.
-
Verify that the user's status isn't
FORCE_CHANGE_PASSWORD. If it is, an administrator created the user and Amazon Cognito prompts them to set a password when they sign in with their temporary password. -
Check that the user has a verified email or phone number attribute.
-
Check your Amazon Simple Email Service (Amazon SES) message-sending quota.
-
For SMS, check your delivery configuration and limits:
-
Confirm that you have moved out of the SMS sandbox. In the sandbox, you can send messages only to verified destination phone numbers.
-
Check your monthly SMS spend limit.
-
Confirm that you have an origination identity, which some destinations require, such as US phone numbers.
-
Confirm the permissions for your SMS path. Amazon Cognito sends SMS messages through AWS End User Messaging SMS, which needs permission for
sms-voice:SendTextMessage, or through the legacy Amazon SNS path, which needs permission forsns:Publish.
-
-
Check whether Amazon SES (if your user pool is configured to Send email with Amazon SES) has been moved out of sandbox. In the sandbox, addresses that Amazon SES hasn't verified can't receive messages.
-
If the user has an active MFA factor, check that they aren't trying to generate a message to the same factor. For example, users with email MFA active can't send password reset codes by email.
-
For more information, see Email settings for Amazon Cognito user pools and SMS message settings for Amazon Cognito user pools.
Password reset fails with unverified recovery attributes: Could not reset password for the account, please contact support or try again
- Problem
-
Users receive this error when they attempt to reset their password.
- Cause
-
The error occurs when the user's email or phone number attribute is unverified, or when their MFA settings prevent using the configured recovery method.
- Solution
-
Review your user pool's account recovery configuration and the affected user's verification status:
-
Verify recovery settings: In your user pool, navigate to Sign In > User Account Recovery. Ensure Self service account recovery is enabled and review your Recovery message delivery method setting.
-
Check user attribute verification: Verify that the user has a verified email address or phone number that matches your recovery method configuration. In the console, go to the user's profile, select User attributes > Edit, and mark the appropriate attribute as verified.
-
Resolve MFA conflicts: Users whose preferred MFA method is email can't receive password-reset codes by email, and users with SMS MFA can't receive codes by SMS. Update your Recovery message delivery method to provide alternative options such as SMS if available, otherwise email or Email if available, otherwise SMS.
-
Administrative verification: Use the API operation AdminUpdateUserAttributes to programmatically verify user attributes when console access isn't available.
-
For more information, see Passwords, account recovery, and password policies.
Exceeded daily email limit for the operation or the account. If a higher limit is required, please configure your user pool to use your own Amazon SES configuration for sending email.
- Problem
-
Email operations return
LimitExceededExceptionwith the messageExceeded daily email limit for the operation or the account. If a higher limit is required, please configure your user pool to use your own Amazon SES configuration for sending email. - Cause
-
Your user pool sends email with the default Amazon Cognito email configuration, which has a limited daily volume.
- Solution
-
Configure your user pool to send email through Amazon SES (the Send email with Amazon SES, or
DEVELOPER, email-sending account) with a verified identity in a supported Region.
For more information, see Email settings for Amazon Cognito user pools and Quotas in Amazon Cognito.
Sign-up, verification codes, and attributes
The following errors occur during sign-up, attribute verification, and attribute updates.
UsernameExistsException and AliasExistsException
- Problem
-
Sign-up or administrative user creation fails because the user name or an alias is already in use.
SignUpreturnsUsernameExistsException(User already exists,An account with the given email already exists., orAn account with the given phone_number already exists.).AdminCreateUserreturnsUser account already exists. A request can also returnAliasExistsException. - Cause
-
The user name is already taken, or an email address or phone number that is configured as an alias is already associated with another user. With an alias, users can sign in with an email address or phone number in addition to their user name. A username attribute, by contrast, makes the email address or phone number the user name itself.
- Solution
-
-
Use a different user name.
-
If the alias is already taken, have the user sign in or recover the existing account instead of creating a new one.
SignUpreturnsUsernameExistsExceptionfor a user name that is already taken even when the app client has Prevent user existence errors enabled. We recommend verification-based aliases so that Amazon Cognito doesn't reveal whether an email address or phone number already exists. -
For more information, see Working with user attributes.
Invalid verification code provided, please try again. and Invalid code provided, please request a code again.
- Problem
-
Confirmation or verification fails.
CodeMismatchExceptionreturnsInvalid verification code provided, please try again.andExpiredCodeExceptionreturnsInvalid code provided, please request a code again.The MFA variant isInvalid code or auth state for the user. - Cause
-
The submitted code doesn't match the latest code that Amazon Cognito sent, or the code expired.
- Solution
-
Request a new code and use the most recent one. Codes have a limited validity period: sign-up confirmation and attribute verification codes are valid for 24 hours, forgot-password (account recovery) codes for 1 hour, and MFA codes for 3–15 minutes.
For more information, see Quotas in Amazon Cognito.
Username cannot be of email format, since user pool is configured for email alias.
- Problem
-
SignUpreturnsInvalidParameterExceptionwithUsername cannot be of email format, since user pool is configured for email alias.The phone number variant isUsername cannot be of phone number format, since user pool is configured for phone number alias. - Cause
-
Your user pool uses email (or phone number) as an alias attribute, so the user name can't itself be an email address (or phone number).
- Solution
-
Submit a user name that isn't an email address or phone number, such as a UUID, and pass the email address as an attribute. If you want users to sign in with an email address as the user name itself, create a new user pool with email as a username attribute. You can't change the username attributes after you create a user pool.
For more information, see Working with user attributes.
Invalid user attributes: attribute: Attribute cannot be updated.
attribute: Attribute cannot be updated.- Problem
-
An attribute update returns
InvalidParameterExceptionwithInvalid user attributes:attribute: Attribute cannot be updated. - Cause
-
The attribute is immutable. You set an attribute's mutability when you create the user pool, and you can't change it afterward.
- Solution
-
Write or map only mutable attributes. To list the immutable attributes in your user pool, run the following AWS CLI command:
aws cognito-idp describe-user-pool --user-pool-iduser-pool-id--query 'UserPool.SchemaAttributes[?Mutable==`false`].Name'
For more information, see Standard attributes.
Invalid phone number format.
- Problem
-
A request returns
InvalidParameterExceptionwithInvalid phone number format. - Cause
-
The phone number isn't in E.164 format.
- Solution
-
Format phone numbers as E.164: a plus sign, the country code, and the subscriber number, with no spaces or other separators. For example,
+12065550100.
For more information, see Working with user attributes.
The Amazon Cognito console chooses a default configuration for a new user pool
- Problem
-
When you set up a new user pool in the console, Amazon Cognito chooses several default settings for you. Some settings can't be changed after the user pool is created. You need to know which settings Amazon Cognito chose for you so that you can make informed choices.
- Cause
-
The new user pool setup in the Amazon Cognito console is designed for rapid testing and prototyping. The console presents you with only the most critical configuration choices, those that can't be changed after user pool creation. You can modify all other settings that Amazon Cognito configures automatically later.
- Solution
-
We recommend the following approach:
-
Use the console to create test user pools while you refine your implementation.
-
After you've determined your production configuration, apply those settings to your test user pools.
-
Use DescribeUserPool and DescribeUserPoolClient API operations to generate JSON templates of your tested configuration.
-
Use these templates with deployment tools like the AWS SDKs, CDK, REST API, or CloudFormation to create your production resources.
-
For more information, see Create a new application in the Amazon Cognito console.
Lambda triggers
The following errors occur when Amazon Cognito invokes an AWS Lambda trigger in your user pool.
InvalidLambdaResponseException and UnexpectedLambdaException
- Problem
-
A Amazon Cognito Lambda trigger fails because the function didn't respond in time or returned output that Amazon Cognito couldn't use.
- Cause
-
Amazon Cognito must receive a response from a Lambda trigger within 5 seconds, and you can't change this limit. If the call can be retried, Amazon Cognito might retry it. A function that returns malformed or unrecognizable output causes
InvalidLambdaResponseException. An invocation failure, such as a timeout, causesUnexpectedLambdaException. - Solution
-
Return the event object with the response fields that the trigger expects. Keep trigger code fast, and offload slow work to an asynchronous process.
For more information, see Things to know about Lambda triggers.
trigger name invocation failed due to error AccessDeniedException.
trigger name invocation failed due to error AccessDeniedException.- Problem
-
A trigger fails with
trigger nameinvocation failed due to error AccessDeniedException. - Cause
-
The function's resource-based policy doesn't allow the Amazon Cognito service principal to invoke it, or the function was deleted. This is common when you configure a trigger with the AWS CLI, an SDK, CloudFormation, or AWS CDK, because the console adds the invoke permission automatically but those paths don't.
- Solution
-
Add a resource-based policy permission that lets the Amazon Cognito service principal,
cognito-idp.amazonaws.com, invoke the function. Scope the permission with theaws:SourceArncondition set to your user pool ARN and theaws:SourceAccountcondition set to your account. If the function was deleted, point the trigger at an existing function.
For more information, see Things to know about Lambda triggers.
Migrate user trigger errors
- Problem
-
The migrate user Lambda trigger fails during sign-in or forgot-password migration. Errors include
Exception migrating user in app client(returned asclient-idUserNotFoundException), sometimes with a reason such as an invalid user name, a missingemail,phone_number, orpreferred_username, an invalidmessageAction, or an invaliddeliveryMedium. Another error isError during migration: invalid finalUserStatus. - Cause
-
The trigger isn't configured correctly, the app client doesn't allow the required flow, the function returned attributes that aren't in the pool schema, or
finalUserStatusis invalid. - Solution
-
-
Grant Amazon Cognito permission to invoke the function.
-
Allow
USER_PASSWORD_AUTHorADMIN_USER_PASSWORD_AUTHon the app client. -
Set
finalUserStatustoCONFIRMEDto let users sign in with their existing password, or toRESET_REQUIREDto require a password reset. Any other value returnsError during migration: invalid finalUserStatus. -
Return only attributes that exist in your pool schema, and prefix custom attributes with
custom:.
-
For more information, see Migrate user Lambda trigger.
Federation
The following errors occur when users federate into Amazon Cognito through SAML 2.0, social, or OpenID Connect (OIDC) identity providers.
Invalid SAML response errors in federation
Users receive various Invalid SAML response and similar errors when they attempt to federate into Amazon Cognito using SAML 2.0. These errors can occur because of attribute mapping issues, certificate problems, or configuration mismatches.
Invalid user attributes: Required attribute
- Problem
-
A user is missing a value for an attribute that is required in your user pool, or the IdP is attempting to remove or update an immutable attribute.
- Solution
-
-
Check the required attributes defined in your user pool configuration.
-
Using network capture tools in your browser, retrieve the SAML response. You might need to perform URL and base64 decoding. Verify the attribute is present in the SAML assertion.
-
Sign in to your identity provider and review the attributes that it sends to Amazon Cognito. Verify that the IdP is configured to send the required attribute using the correct name.
-
For immutable attributes, run the following AWS CLI command to identify them:
aws cognito-idp describe-user-pool --user-pool-iduser-pool-id--query 'UserPool.SchemaAttributes[?Mutable==`false`].Name' -
In the SAML attribute mappings of your IdP, delete any mapping that targets an immutable Amazon Cognito attribute. Alternately, update the destination attribute to a different, mutable attribute.
-
Invalid SAML response received: SAML Response signature is invalid
- Problem
-
Your IdP has updated its SAML signing certificate, causing a mismatch between the certificate in the SAML response and the metadata file stored in Amazon Cognito.
- Solution
-
-
Download the latest metadata file from your IdP.
-
In the Amazon Cognito console, navigate to the Social and external providers for your user pool, edit your SAML provider, and replace the existing metadata file with the newly downloaded file.
-
Audience restriction or Application with identifier not found
- Problem
-
An incorrect Entity ID is configured in your IdP, or the assertion uses another user pool's Uniform Resource Name (URN).
- Solution
-
-
Get your Amazon Cognito user pool ID from the Overview section in the console.
-
In the management console for your IdP, update the entity ID in the SAML application for your user pool. Configure the entity ID to match the format
urn:amazon:cognito:sp:. Replaceuser-pool-iduser-pool-idwith the user pool ID from the previous step.
-
An error was encountered with the requested page
- Problem
-
The Assertion Consumer Service (ACS) URL registered with your IdP is incorrectly configured, or the IdP is not sending the SAML response using the required POST binding.
- Solution
-
-
In the management console for your IdP, update the application with the correct ACS URL format, ensuring it uses the
HTTP POSTbinding. -
Default domain format:
https://cognito-idp.Region.amazonaws.com/user-pool-id/saml2/idpresponse -
Custom domain format:
https://auth.example.com/saml2/idpresponse
-
Invalid relayState from identity provider
- Problem
-
The
RelayStateparameter is missing or invalid, or the URL is mismatched between the IdP and Amazon Cognito. - Solution
-
-
For service provider initiated (SP-initiated) flows: Always start the authentication at your user pool
/oauth2/authorizeendpoint. SAML assertions that don't returnRelayStateparameters from the user's initial visit to Amazon Cognito are not valid SP-initiated requests. -
For identity provider initiated (IdP-initiated) flows: The IdP must include the
RelayStateparameter with the SAML assertion to the/saml2/idpresponseendpoint, using the required format:redirect_uri=REDIRECT_URI&state=STATE.
-
For more information, see Using SAML identity providers with a user pool.
attributes required: [email] for social and OIDC providers
- Problem
-
Federated sign-in with a social or OIDC identity provider fails with
attributes required: [email](orusername attribute mapping required). - Cause
-
A user pool attribute that is required isn't mapped from the IdP, or the IdP didn't return it.
- Solution
-
-
Request the scopes that return the attribute you need, such as
email. -
Map the required attributes from the IdP to your user pool, and map the IdP
email_verifiedclaim. -
Remove a mapping only for an optional attribute that the IdP doesn't send. Don't unmap a required attribute to silence the error.
-
For more information, see Mapping IdP attributes to profiles and tokens and Setting up a social IdP.
Identity pools
The following errors occur when an identity pool exchanges tokens for temporary AWS credentials.
Token is not from a supported provider of this identity pool.
- Problem
-
A
GetIdorGetCredentialsForIdentityrequest returnsNotAuthorizedExceptionwithToken is not from a supported provider of this identity pool. - Cause
-
The
Loginsmap key or the token doesn't match a provider that is configured on the identity pool. For a user pool provider, the key iscognito-idp., and the token's app client ID must be registered with that provider on the identity pool.Region.amazonaws.com/userPoolId - Solution
-
Use a
Loginskey that matches a configured provider, and register the token's app client ID with that provider.
For more information, see Identity pools external identity providers.
Invalid identity pool configuration. Check assigned IAM roles for this pool.
- Problem
-
A
GetCredentialsForIdentityrequest returnsInvalidIdentityPoolConfigurationExceptionwithInvalid identity pool configuration. Check assigned IAM roles for this pool. - Cause
-
The identity pool has no role assigned for the authentication type, or the role's trust policy doesn't allow the identity pool to assume it. The role's trust policy must allow the
sts:AssumeRoleWithWebIdentityaction for thecognito-identity.amazonaws.comprincipal, with thecognito-identity.amazonaws.com:audcondition set to your identity pool ID and thecognito-identity.amazonaws.com:amrcondition set toauthenticatedorunauthenticated. - Solution
-
Assign a role for the authentication type, and set the role's trust policy to allow the identity pool to assume it with the conditions described.
For more information, see IAM roles.
Unauthenticated access is not supported for this identity pool.
- Problem
-
A request returns
NotAuthorizedExceptionwithUnauthenticated access is not supported for this identity pool. - Cause
-
The request didn't include any
Logins, but the identity pool doesn't allow guest (unauthenticated) access. - Solution
-
Either send a
Loginsmap with a valid provider token, or turn on guest access and assign an unauthenticated role. If you turn on guest access, anyone on the internet can get temporary AWS credentials. Grant the unauthenticated role only the minimum permissions it needs.
For more information, see Using role-based access control.
Custom domain configuration errors
When you configure custom domain names in Amazon Cognito, you might receive error messages. Common errors include validation issues, certificate problems, or domain conflicts.
Custom domain is not a valid subdomain
- Problem
-
Custom domain creation fails with
Custom domain is not a valid subdomain. - Cause
-
This error indicates an issue with DNS resolution for the parent domain. Amazon Cognito doesn't support top-level domains and requires the parent domain to have a DNS A record for validation.
- Solution
-
-
Create an A record for the parent domain: You must create an A record in your DNS configuration for the parent domain of your custom domain.
-
Example: If your custom domain is
auth.xyz.example.com, the parent domain isxyz.example.com. If you want to configurexyz.example.comas a custom domain, the parent isexample.com. -
The parent domain must resolve to a valid IP address. If it doesn't point to a real IP address, you can point its A record to a placeholder IP address, as described on the custom domain setup page.
-
-
(Optional) Verify DNS propagation: To ensure your DNS provider has propagated the change, you can run a
digcommand.-
If using
auth.xyz.example.comas the custom domain:dig A xyz.example.com +short -
If using
xyz.example.comas the custom domain:dig A example.com +short -
The command should return the IP address you configured. If it doesn't, wait until the change has fully propagated.
-
-
Remove the parent domain A record: After you successfully create the custom domain in Amazon Cognito, you can remove the A record you created for the parent domain if it was a placeholder.
-
For more information, see Using your own domain for managed login.
Domain already associated with another user pool
- Problem
-
Custom domain creation fails because the domain name is already in use. Custom domain names must be unique across all AWS accounts and Regions.
- Cause
-
The domain name is already associated with another user pool.
- Solution
-
-
To use the domain name for a new user pool, you must delete the custom domain from the user pool it's currently associated with.
-
Wait after deletion: It takes time for the custom domain to fully delete from the first user pool. Creating a new custom domain with the same name immediately after deletion might still result in this error. Wait a few minutes before trying again.
-
One or more of the CNAMEs that you provided are already associated with a different resource
- Problem
-
Custom domain creation fails with
One or more of the CNAMEs that you provided are already associated with a different resource. - Cause
-
When you create a custom domain, Amazon Cognito creates an AWS-managed Amazon CloudFront distribution. A domain name can only be used with one Amazon CloudFront distribution. This error occurs if the domain name is already in use as an alternate domain for another Amazon CloudFront distribution.
- Solution
-
-
Option 1: Use a different domain name for your Amazon Cognito custom domain.
-
Option 2: If you use the domain name for Amazon Cognito, don't use it with another Amazon CloudFront distribution.
-
The specified SSL certificate doesn't exist
- Problem
-
Custom domain creation fails with
The specified SSL certificate doesn't exist. - Cause
-
Amazon Cognito uses Amazon CloudFront, which requires the AWS Certificate Manager (ACM) certificate to be in the
us-east-1(N. Virginia) AWS Region, regardless of the user pool's Region. - Solution
-
-
Ensure certificate Region: Confirm the ACM certificate is in the
us-east-1Region. -
Check certificate validity: Make sure the selected certificate isn't expired.
-
Imported certificates: If you imported the certificate into ACM, ensure:
-
It was issued by a public certificate authority.
-
It includes the correct certificate chain.
-
-
AWS KMS policy check: An explicit
denystatement in an AWS Key Management Service (AWS KMS) policy for the IAM user or role creating the domain can cause this error. Specifically, check for explicit denials onkms:DescribeKey,kms:CreateGrant, orkms:*actions.
-
Quotas and throttling
TooManyRequestsException and throttling
- Problem
-
Requests return
TooManyRequestsException. - Cause
-
Your request rate exceeded the quota for an operation category.
RespondToAuthChallengeandAdminRespondToAuthChallengehave their own quota, which is three times the quota of theUserAuthenticationcategory. - Solution
-
Retry with exponential backoff and jitter, cache tokens instead of re-authenticating, and reduce redundant calls. If you need a higher limit, request a quota increase in Service Quotas.
For more information, see Quotas in Amazon Cognito.
Additional troubleshooting resources
For additional troubleshooting guidance, you can also explore the following external resource:
-
AWS Knowledge Center Amazon Cognito articles
- Curated troubleshooting articles