I am trying to access some basic user attributes from a React app and okta-auth-js, as seen in the description of the User Model
{
"id": "00ub0oNGTSWTBKOLGLNR",
"status": "ACTIVE",
"created": "2013-06-24T16:39:18.000Z",
"activated": "2013-06-24T16:39:19.000Z",
"statusChanged": "2013-06-24T16:39:19.000Z",
"lastLogin": "2013-06-24T17:39:19.000Z",
"lastUpdated": "2013-06-27T16:35:28.000Z",
"passwordChanged": "2013-06-24T16:39:19.000Z",
// ...
}
I started with only sub
, email
and email_verified
. I configured Okta with scope: 'openid profile'
, and following this answer, I added user
as a claim:
However all I get are normal user attributes, such as given_name
, locale
, or the extended profile attributes such as city
, employeeNumber
, manager
and so on.
I read in this old StackOverflow question that a GET request to my endpoint will give me the information I want, but I am not fetching manually, I am using this getUser
function instead:
async getUser() {
const accessToken = await this._oktaAuth.tokenManager.get('accessToken');
const idToken = await this._oktaAuth.tokenManager.get('idToken');
if (accessToken && idToken) {
const userinfo = await this._oktaAuth.token.getUserInfo(accessToken);
if (userinfo.sub === idToken.claims.sub) {
// Only return the userinfo response if subjects match to
// mitigate token substitution attacks
return userinfo
}
}
return idToken ? idToken.claims : undefined;
}
How do I get lastLogin, created, passwordChanged user attributes?
Thank you!