Hi, i’m using the Okta javascript SDK and I’m wondering if the getUser() function can also return the access_token? just so I don’t have to make two calls to the API on page load, like…
const accessToken = await this.props.auth.getAccessToken();
const userinfo = await this.props.auth.getUser();
What information do you want from the user? You might be able to parse the access token for some of the user’s information.
Hi @johnantoni, it looks like you’re using okta-react (we have a bunch of different js SDKs). getAccessToken simply pulls out of localStorage if it’s available (it only makes a request if it’s expired). This happens automatically when you call getUser(), so unless you need the access token, you can just call getUser.
Ideally I’d like the user’s unique id so I can have a user record stored in my database that i can link to their Okta account.
I reckon the sub attribute I get from the getUser() call is unique so I’ll use that.
I’ll also need their username, email, if email verified for the app’s UI.
So if I can also get the access_token all in one call that’d be great.