# Is it possible to get Okta session token with OAuth flow

**URL:** <https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660>\
**Category:** OAuth/OIDC\
**Created:** [January 28, 2021, 6:23am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660 "2021-01-28T06:23:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![misha](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/misha/32/2544_2.png) [@misha](https://devforum.okta.com/u/misha)\
**Post date:** [January 28, 2021, 6:23am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/1 "2021-01-28T06:23:17Z")

</div>

I can see how to get session token and session cookie via authn API.  
But is it possible to get the same via OAuth flow?

Currently with OAuth flow I can only get access token  
Thanks

---

<div class="post-metadata">

**Author:** ![rajnadimpalli](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rajnadimpalli](https://devforum.okta.com/u/rajnadimpalli)\
**Post date:** [January 28, 2021, 6:32am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/2 "2021-01-28T06:32:36Z")

</div>

Hi @misha,

Session token is one-time bearer token that provides proof of authentication.  
If you have a session token, you can use that to obtain an OAuth access token but the other way around is not possible.

Thank you,  
Raj

---

<div class="post-metadata">

**Author:** ![misha](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/misha/32/2544_2.png) [@misha](https://devforum.okta.com/u/misha)\
**Post date:** [January 28, 2021, 10:58pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/3 "2021-01-28T22:58:54Z")

</div>

Thank you for your reply @rajnadimpalli  
What s the alternative? My app supports OAuth flow and I need session cookie.  
Is there a way to get it without implementing webauthn?

---

<div class="post-metadata">

**Author:** ![devpascoe](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/devpascoe/32/4640_2.png) [@devpascoe](https://devforum.okta.com/u/devpascoe)\
**Post date:** [March 29, 2023, 5:29am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/4 "2023-03-29T05:29:50Z")

</div>

I too have a situation where i need both sessionToken and accessToken. I can exchange sessionToken for accessToken and thats fine for API requests. But related SSO webpages which use sessionToken (/login/sessionCookieRedirect) work fine for first couple hours. But once sessionToken expires thats it. Any way to re-issue sessionToken without a full MFA process again?

---

<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:** [March 29, 2023, 3:55pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/5 "2023-03-29T15:55:36Z")

</div>

Be careful with mixing up the sessionToken with the [session _cookie_](https://developer.okta.com/docs/reference/api/sessions/#session-cookie) that Okta will set when the sessionToken is exchanged. See this doc for the different options for exchanging a sessionToken for a full Okta session: [Sessions | Okta Developer](https://developer.okta.com/docs/reference/api/sessions/#session-token).

If the session _cookie_ is expiring, its because the user is not actively using Okta and having is session renewed automatically, even if they may be actively using the OIDC app for which they have an Access/ID Token. This is expected behavior, as the Okta session is only needed to initially log the user into the OIDC app, but the OIDC app itself is _not_ dependent on the Okta session.

If you really want to look into keeping it alive anyway, you can either look to extend the user’s session via policy, [Enforce a limited session lifetime for all policies | Okta](https://help.okta.com/en-us/Content/Topics/Security/healthinsight/session-lifetime.htm), or you can try to [refresh the session on their behalf](https://developer.okta.com/docs/reference/api/sessions/#refresh-current-session). Note that this final option involves CORS requests to the Okta domain from your application and your mileage may vary with [browsers that block third party cookies](https://support.okta.com/help/s/article/FAQ-How-Blocking-Third-Party-Cookies-Can-Potentially-Impact-Your-Okta-Environment?language=en_US).

---

<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:55am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth-flow/12660/6 "2024-02-13T00:55:29Z")

</div>

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

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