# Can getUser() also return the access\_token?

**URL:** <https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065>\
**Category:** Questions\
**Created:** [January 17, 2018, 5:17pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065 "2018-01-17T17:17:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnantoni](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/johnantoni/32/289_2.png) [@johnantoni](https://devforum.okta.com/u/johnantoni)\
**Post date:** [January 17, 2018, 5:17pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/1 "2018-01-17T17:17:29Z")

</div>

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();
```

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [January 17, 2018, 5:37pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/2 "2018-01-17T17:37:28Z")

</div>

What information do you want from the user? You might be able to parse the access token for some of the user’s information.

---

<div class="post-metadata">

**Author:** ![lboyette](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@lboyette](https://devforum.okta.com/u/lboyette)\
**Post date:** [January 17, 2018, 5:57pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/3 "2018-01-17T17:57:12Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![johnantoni](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/johnantoni/32/289_2.png) [@johnantoni](https://devforum.okta.com/u/johnantoni)\
**Post date:** [January 17, 2018, 5:57pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/4 "2018-01-17T17:57:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johnantoni](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/johnantoni/32/289_2.png) [@johnantoni](https://devforum.okta.com/u/johnantoni)\
**Post date:** [January 17, 2018, 5:58pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/5 "2018-01-17T17:58:39Z")

</div>

interesting, thanks.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [January 12, 2024, 11:16pm UTC](https://devforum.okta.com/t/can-getuser-also-return-the-access-token/1065/7 "2024-01-12T23:16:18Z")

</div>

Closed on January 12, 2024, 11:16pm UTC


