Getting your identifier id

In my SPA, I want to get the okta user-id when I call this function:

const user = await this.$auth.getUser()

but at the moment, it returns the sub-attribute which has the app client id for my SPA

I did some research and found the expression user.getInternalProperty("id"), but it is also returning the app client id.

My current setting:
scopes: [‘openid’, ‘profile’, ‘email’],
pkce: true,
response_type: ‘id_token’

What is the right way to getting the user id?

hmm… that’s odd.

The getUser method should be making a call to the userinfo endpoint and, provided the token you are sending to the endpoint was issued to an end-user, the ‘sub’ value returned should be the user’s ID in your Okta org, see the example in our docs here.

If you log into your application, grab the raw JWT ID token (you can find it stored in Local/Session/Cookie Storage, depending on which you chose but local should be the default, with the key okta-token-storage), and decode the token, do you see the user’s ID as the sub claim value?

Yes, I see it now. My fault, the client id, and the user id were very similar, except for 3 characters. After, decoding it, I was able to compare the values.


This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.