Amplify-js: Returning user custom attributes

Created on 3 Apr 2018  路  8Comments  路  Source: aws-amplify/amplify-js

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?

documentation question

Most helpful comment

Hey @nomadus have you tried userAttributes?

Auth.currentAuthenticatedUser()
  .then(user => Auth.userAttributes(user))
  .then(attributes => console.log(attributes))
  .catch(err => console.log(err));

All 8 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benevolentprof picture benevolentprof  路  3Comments

epicfaace picture epicfaace  路  3Comments

karlmosenbacher picture karlmosenbacher  路  3Comments

DougWoodCDS picture DougWoodCDS  路  3Comments

callmekatootie picture callmekatootie  路  3Comments