amplify-js: Amplify currentUserinfo returns null

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker

Describe the bug When I used authenticationFlowType: 'USER_PASSWORD_AUTH' in my configuration of amplify. After I signin with my usrname and password then Auth.currentUserInfo() is returning null.

I doubled checked it. If I remove authenticationFlowtype it shows all the user properties

To Reproduce Steps to reproduce the behavior:

  1. Go to ‘config file and add authenticationFlowType: ‘USER_PASSWORD_AUTH’’
  2. check on ‘.Auth.currentUserInfo()’
  3. See Null

Expected behavior It should return user attributes

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 50 (8 by maintainers)

Most upvoted comments

@jmandivarapu1 as a temporary patch, can you see if you can use this to replace currentUserInfo?

//inside async function
const attributes = (await Auth.currentSession()).getIdToken().payload

(that’s the syntax off the top of my head, you may need log currentSession() to see how to get the idToken payload if that doesn’t work)

Any update?

@jmandivarapu1 why do you need USER_PASSWORD_AUTH instead of USER_SRP_AUTH?

i am glad you used. It all started with the crazy amplify analytics.

https://github.com/aws-amplify/amplify-cli/issues/2593

@jmandivarapu1 for getting user attributes I used this:

let { attributes } = await Auth.currentAuthenticatedUser();

@jmandivarapu1 run the command I gave you to get the custom attributes…

const attributes = (await Auth.currentSession()).getIdToken().payload

The id token’s payload includes all token attributes. currentUserInfo is probably only provided as an optimization or convenience function, assuming it checks locally before sending a network request.

Yeah I like the idea. But don’t know what’s happening why session is null and all.

But it’s throwing error No current user.

But when I did var cognito_resp= await Auth.signIn(this.state.email, this.state.password);

Screen Shot 2019-10-17 at 10 30 21 PM