- Newest
- Most votes
- Most comments
You are correct that the Amazon Cognito documentation mentions a Session attribute in the response of the Sign Up operation. However, there seems to be a discrepancy between the documentation and the actual behavior of the service.
The Sign Up operation in Amazon Cognito is designed to register a new user in a user pool. While the documentation suggests that a Session attribute should be returned, which could be used for immediate sign-in after confirmation, this feature may not be consistently implemented or available in all scenarios.
It's important to note that the typical flow for user registration and confirmation in Cognito involves two separate steps:
- Sign Up: This creates the user account but typically leaves it in an unconfirmed state.
- Confirm Sign Up: This confirms the user account, usually by verifying a code sent to the user's email or phone.
After these steps, you would normally use a separate authentication flow to sign the user in.
If you're not seeing the Session attribute in the response, you're not doing anything wrong. The recommended approach would be to proceed with the standard flow:
- Use the Sign Up command to create the user account.
- Have the user enter the confirmation code they received.
- Use the Confirm Sign Up command to confirm the account.
- After confirmation, use the appropriate authentication method to sign the user in.
If you need to implement immediate sign-in after confirmation, you might want to consider using the AdminCreateUser API instead, which creates a confirmed user and provides temporary credentials for immediate sign-in. However, this approach requires administrative privileges and is typically used for scenarios where you're creating users on their behalf, rather than self-service sign-up.
If this functionality is critical for your use case, you may want to reach out to AWS support for clarification on the current behavior of the Sign Up API and the availability of the Session attribute.
Sources
sign-up — AWS CLI 2.22.15 Command Reference
Signing up and confirming user accounts - Amazon Cognito
answered 2 years ago
From: https://github.com/aws/aws-sdk-js-v3/issues/6724#issuecomment-2574143299
SignUp only will return "Session" when the client has turned on User_Auth. Client setting link: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolClient.html#CognitoUserPools-CreateUserPoolClient-request-ExplicitAuthFlows The reason of this behavior is because only User_Auth flow can use this session from SignUp to authenticate directly after sign up. All other auth flows, the session can not be used / will not take any effect. This is intended behavior.
Verified on: https://github.com/aws/aws-sdk-js-v3/issues/6724#issuecomment-2577522883
answered 2 years ago
Relevant content
asked 3 years ago
