# Get Okta users API with sessionToken

**URL:** <https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157>\
**Category:** OAuth/OIDC\
**Created:** [July 17, 2021, 10:55am UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157 "2021-07-17T10:55:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![guillemsola](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/guillemsola/32/3136_2.png) [@guillemsola](https://devforum.okta.com/u/guillemsola)\
**Post date:** [July 17, 2021, 10:55am UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/1 "2021-07-17T10:55:30Z")

</div>

I have an Okta admin account for some applications to manage users. I noticed that once logged into the Okta admin site I can make a GET request to `https://myoktadomain/api/v1/users/john.doe@mycompany.com` and see in JSON format the user details as in the Okta admin screen.

To perform a one-off migration I would like to get certain user attributes present in Okta programmatically querying the Okta user endpoint.

Playing with Postman I see I can get a `sessionToken` calling `/api/v1/authn`. The `/api/v1/users/` examples I see in Okta doc use `SSWS {{apikey}}` in the `Authorization` header. Trying with my `sessionToken` only returns a _Invalid token provided_ or _Invalid session provided_ error message.

Is there a way to call the `/api/v1/users/` endpoint with a `sessionToken`? maybe I can get an `apiKey` with it? or the only way to make Okta API requests is by getting an `apiKey` from a super-admin?

---

<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:** [July 19, 2021, 5:54pm UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/2 "2021-07-19T17:54:42Z")

</div>

The sessionToken is proof that a user has logged into Okta and is designed to be [exchanged for a session cookie](https://developer.okta.com/docs/reference/api/sessions/#create-session-with-a-session-token) so that user can SSO. It cannot be used to perform admin actions.

If the API call you are looking to make requires an SSWS, that means an admin needs to perform that action, which yes, would meant that they would need [generate an API token](https://developer.okta.com/docs/guides/create-an-api-token/overview/) and make the request with it. You cannot get an API key via API, only via the admin portal.

Aside from the API token, you CAN request and use OAuth tokens to make these requests, but the same general rule applies. If the [tokens are requested by an individual](https://developer.okta.com/docs/guides/implement-oauth-for-okta/overview/), they must have adequate [Admin permissions](https://help.okta.com/en/prod/Content/Topics/Security/administrators-admin-comparison.htm) for their account to make the request. If the [tokens are requested by a client (service app)](https://developer.okta.com/docs/guides/implement-oauth-for-okta-serviceapp/overview/), they will have the same permissions as a super admin.

---

<div class="post-metadata">

**Author:** ![guillemsola](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/guillemsola/32/3136_2.png) [@guillemsola](https://devforum.okta.com/u/guillemsola)\
**Post date:** [July 19, 2021, 9:01pm UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/3 "2021-07-19T21:01:58Z")

</div>

thanks, I was able to get an API token and with that all can be done as per doc.

My curiosity started as once logged as admin in the browser I was able to access that API with the browser cookies. So it seems there may be some undocumented use cases. My guess is because this is the same mechanism that the admin UI uses to access the okta API. But as you said the suggested method is with a SSWS token.

---

<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:** [July 19, 2021, 9:32pm UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/4 "2021-07-19T21:32:44Z")

</div>

You’re right, the admin console behaves a bit differently and is thus dependent only on the Okta session existing in the browser. We do support doing so for CORS requests and you’ll see which endpoints support CORS in our API docs, and you will find that not all endpoints support CORS at this time: [Users | Okta Developer](https://developer.okta.com/docs/reference/api/users/#get-user)

While not an officially supported project, an Okta employee created a Chrome extension, [Rockstar](https://gabrielsroka.github.io/rockstar/), that makes use of this functionality so you can make API calls in the browser, which might be of interest.

---

<div class="post-metadata">

**Author:** ![nlara](https://avatars.discourse-cdn.com/v4/letter/n/898d66/32.png) [@nlara](https://devforum.okta.com/u/nlara)\
**Post date:** [October 18, 2022, 12:05am UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/5 "2022-10-18T00:05:37Z")

</div>

Hi Andrea,

I have the same requirement as @guillemsola the only difference is I need to keep using Auth2 Authorization Code Flo + PKCE. I wish to be able to retrieve our users from Okta. As of now, I cannot do it because the token I am getting does not have the “okta.users.read” scope. Please help as I don’t know what else I need.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [February 13, 2024, 12:27am UTC](https://devforum.okta.com/t/get-okta-users-api-with-sessiontoken/15157/6 "2024-02-13T00:27:20Z")

</div>

Closed on February 13, 2024, 12:27am UTC

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