Auth.currentAuthenticatedUser() does not return Cognito User.

0

Auth.currentAuthenticatedUser() only returns google token like so:

{
    "id": "us-east-1:xxxxx",
    "name": "xxx",
    "token": "xxxxxx"
}
const googleToken = response.credential;
    const googleData = parseToken(googleToken);
    console.log('googleData:', googleData);
    const { email, given_name, exp } = googleData;
    Auth.federatedSignIn(
      'google',
      {
        token: googleToken,
        expires_at: exp
      },
      {
        name: given_name
      }
    ).then((response) => {
      console.log('federatedSignIn res', response);
      // Use the Auth.currentAuthenticatedUser() method to check if the user is already authenticated
      Auth.currentAuthenticatedUser()
        .then((cognitoUser) => {
          console.log('cognitoUser:', cognitoUser);
          const cognitoToken =
            cognitoUser.signInUserSession.accessToken.jwtToken;
          // Use the Cognito token to authenticate requests to your backend API
          console.log('cognitoToken:', cognitoToken);
        })
No Answers

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.

Guidelines for Answering Questions