I am looking a guaranteed way to return user attributes.
I have set one custom attribute, which is an accountId and it is a key information to retrieve user details from the database.
When I call Auth.currentAuthenticatedUser() it sometimes (when user just signed up and logins first time), does not return user attributes. What API function should I use which always returns the user attributes?
Hey @nomadus have you tried userAttributes?
Auth.currentAuthenticatedUser()
.then(user => Auth.userAttributes(user))
.then(attributes => console.log(attributes))
.catch(err => console.log(err));
@richardzcode Your code is throwing an error with [email protected]
The error is:
TypeError: user.getSession is not a function
The error is thrown here:
https://github.com/aws/aws-amplify/blob/257a41a384fe0086cdf24c5f82890ec3c143217f/packages/aws-amplify/src/Auth/Auth.ts#L759
The reason is that Auth.currentAuthenticatedUser is no longer returning a CognitoUser object, for whatever reason. It was working at [email protected]. This is breaking my app so please help.
Bump. It looks like this is still broken. What's the correct way to get the updated custom user attributes?
I Have the same problem, do you have any answer about this behavior ?
I'm having this problem too
[email protected] should have fixed this issue. #859
Looks like this is still an issue.
Hm, so how can I get all custom attributes? I tried by setting read and writable permissions, byPassCache: true as option, nothing worked
Most helpful comment
Hey @nomadus have you tried
userAttributes?