AWS Cognito Token Issues

0

try { var data = await Auth.signIn(values.email, values.password); console.log("data",data);

  if (data.signInUserSession) {
    const accessToken = data.signInUserSession.accessToken.jwtToken;
    console.log("Access Token: " + accessToken);
  } else {
    console.log("Authentication succeeded but no user session found.")
  }
} catch (error) {
  console.error("Authentication error:", error);
}


setRemember(values.remember);
// login(values);

};

I have called Cognito for login. login succeeds but token not yet return, like id token , refresh token, ect... and i am not using any lambda tragger.

i got the messge like : Authentication succeeded but no user session found.

1개 답변
0

Hello,

I understand that Cognito JWT tokens are not returned when Amplify makes the REST API call Auth.signIn().

With Auth.signIn() API you pass the username and password to the signIn method of the Auth class to enable username and password sign-in.

[+] Sign In a user : https://docs.amplify.aws/lib/auth/emailpassword/q/platform/js/#sign-in

Auth.signIn() returns a CognitoUser Object as defined in the API Docs.

[+] API docs: https://aws-amplify.github.io/amplify-js/api/classes/authclass.html#signin

The user variable is a CognitoUser Object, which represents a single CognitoUser. The JWT Token in stored in the CognitoUser.CognitoUserSession attribute .

[+] CognitoUser : https://aws-amplify.github.io/aws-sdk-android/docs/reference/com/amazonaws/mobileconnectors/cognitoidentityprovider/CognitoUser.html

The API call updates the CognitoUser with session and token JWT. After Auth.signIn() the user Object would have been updated if AWS issued tokens. After successfully authenticating a user, Amazon Cognito issues JSON web tokens (JWT) that you can use to secure and authorize access to your own APIs, or exchange for AWS credentials.

That being said, to further look into this issue more closely, if you would like to do a resource based troubleshooting, please raise a support case with AWS for further information. If a support case has already been created please be assured that we will get back to you and assist you in the best way possible.

[+] https://console.aws.amazon.com/support/home#/case/create

AWS
Shreeya
답변함 7달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인