Skip to content

Cognito Sign Up Session not

0

The Cognito Sing Up documentation indicates that the response will include a Session that you can pass to ConfirmSignUp when you want to immediately sign in your user.

However, when interacting with the Sign Up Command it is not returning a Session attribute in the response. I've tried with the Node.JS SDK and AWS CLI (2.16.3) and could not make it work.

Enter image description here

asked 2 years ago317 views

2 Answers
0

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:

  1. Sign Up: This creates the user account but typically leaves it in an unconfirmed state.
  2. 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:

  1. Use the Sign Up command to create the user account.
  2. Have the user enter the confirmation code they received.
  3. Use the Confirm Sign Up command to confirm the account.
  4. 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

0

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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.