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

**URL:** <https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750>\
**Category:** OAuth/OIDC\
**Created:** [November 5, 2023, 2:06pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750 "2023-11-05T14:06:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gekaxid811](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@gekaxid811](https://devforum.okta.com/u/gekaxid811)\
**Post date:** [November 5, 2023, 2:06pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750/1 "2023-11-05T14:06:39Z")

</div>

Hey,  
I’m trying to create a session using Okta’s OAuth2 (using api calls only).  
the flow:  
1.User enters my website  
2.I have my own verification mechanism (that does not include password) so user go through it.  
3.Somehow if #2 was successful ,I need to create a session and pass to the frontend.

I’m open to suggestions so if OAuth2 is not the right way (or not the best way) please suggest a way 🙂

Thanks in advance !

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [November 5, 2023, 7:48pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750/2 "2023-11-05T19:48:08Z")

</div>

Hi @gekaxid811! You’ll need to get a session token from the Okta Authentication API first and then you can exchange that for a session cookie at the /authorize endpoint (OAuth 2.0 API) see - [Work with Okta session cookies | Okta Developer](https://developer.okta.com/docs/guides/session-cookie/main/#retrieve-a-session-cookie-through-the-openid-connect-authorization-endpoint).

---

<div class="post-metadata">

**Author:** ![gekaxid811](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@gekaxid811](https://devforum.okta.com/u/gekaxid811)\
**Post date:** [November 5, 2023, 9:07pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750/3 "2023-11-05T21:07:40Z")

</div>

Thanks for answering !  
Can I get these token + exchange action without any client’s interaction ?  
I mean , backend to backend architecture.  
In edition , where can I set the cookie’s domain ?

I see that the Auth API says it allows you to verify the username and password credentials for a user, my users don’t have a password.

> **[Authentication | Okta Developer](https://developer.okta.com/docs/reference/api/authn/)**
>
> Secure, scalable, and highly available authentication and user management for any app.

---

<div class="post-metadata">

**Author:** ![sigama](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/sigama/32/5811_2.png) [@sigama](https://devforum.okta.com/u/sigama)\
**Post date:** [November 7, 2023, 6:07pm UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750/4 "2023-11-07T18:07:30Z")

</div>

@gekaxid811 looks like there isn’t another way to get the session token without any client interaction - [OAuth 2.0 and OpenID Connect overview | Okta Developer](https://developer.okta.com/docs/concepts/oauth-openid/#what-type-of-application-are-you-building). Plus -

“A session token is returned after successful authentication, which can be later exchanged for a session cookie…”

> **[Sessions](https://developer.okta.com/docs/api/openapi/okta-management/management/tag/Session/)**
>
> Okta uses a cookie-based authentication mechanism to maintain a user's authentication Session across web requests. The Okta Sessions API provides operations to create and manage authentication Sessions for users in your Okta...

---

<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:** [February 16, 2024, 12:57am UTC](https://devforum.okta.com/t/is-it-possible-to-get-okta-session-token-with-oauth2-flow/25750/5 "2024-02-16T00:57:10Z")

</div>

Closed on February 16, 2024, 12:57am UTC


