How can I get other cognito user attributes like created_at? - amplify-js

Which Category is your question related to? Authentication

What AWS Services are you utilizing? Cognito

Provide additional details e.g. code snippets I can get the user sub, email, and other attributes like first_name by doing this

const user = await Auth.currentAuthenticatedUser()

However, I can't find any way to get the created_at datetime.

Asked Oct 02 '21 22:10
avatar flybayer
flybayer

4 Answer:

@flybayer hi, the only way to achieve that data is to use the AdminGetUser API provided by Cognito team: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminGetUser.html which is not available when using Amplify.

1
Answered Mar 05 '19 at 22:35
avatar  of powerful23
powerful23

@flybayer you could use the admin API suggested by @powerful23 and then store the result as a custom claim in your token during the pre-token generation Cognito trigger. Then you could just access it from the token like any other claim.

1
Answered Mar 09 '19 at 17:34
avatar  of jkeys-ecg-nmsu
jkeys-ecg-nmsu

@flybayer I am going to close this issue. Please let us know if you want to reopen it.

1
Answered Mar 28 '19 at 23:38
avatar  of powerful23
powerful23

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

1
Answered Jun 13 '21 at 00:08
avatar  of github-actions[bot]
github-actions[bot]