# Fetching the User token

**URL:** <https://devforum.okta.com/t/fetching-the-user-token/26995>\
**Category:** OAuth/OIDC\
**Created:** [February 26, 2024, 11:14am UTC](https://devforum.okta.com/t/fetching-the-user-token/26995 "2024-02-26T11:14:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![harishdalmia](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@harishdalmia](https://devforum.okta.com/u/harishdalmia)\
**Post date:** [February 26, 2024, 11:14am UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/1 "2024-02-26T11:14:47Z")

</div>

I am trying to get the user token via Postman for the logged-in user: [anurag.s.sinha@oracle.com](mailto:anurag.s.sinha@oracle.com). Tried with the below API.“[https://dev-10159567.okta.com/oauth2/default/v1/token](https://dev-10159567.okta.com/oauth2/default/v1/token)” but every time it ends up stating- {  
“error”: “invalid\_grant”,  
“error\_description”: “The authorization code is invalid or has expired.”  
}

I have provided the grant\_type, redirect\_uri, client\_id, client\_secret and code. but still end up in the above error.  
I am taking the code after I was logging in from the browser from the network API call and pasting it within 45 seconds.  
Any help or information is appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![harishdalmia](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@harishdalmia](https://devforum.okta.com/u/harishdalmia)\
**Post date:** [February 26, 2024, 6:03pm UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/2 "2024-02-26T18:03:31Z")

</div>

Any help is appreciated. Thank you.

---

<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:** [February 26, 2024, 7:09pm UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/3 "2024-02-26T19:09:40Z")

</div>

Hi @harishdalmia can you test with this tool as well - [https://oidcdebugger.com/](https://oidcdebugger.com/) just to make sure it is not an issue with Postman.

---

<div class="post-metadata">

**Author:** ![harishdalmia](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@harishdalmia](https://devforum.okta.com/u/harishdalmia)\
**Post date:** [February 26, 2024, 11:59pm UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/4 "2024-02-26T23:59:06Z")

</div>

Same 400 Bad Request.  
Your request resulted in an error. The ‘redirect\_uri’ parameter must be a Login redirect URI in the client app settings: [okta-dev-10159567 - Sign In](https://dev-10159567-admin.okta.com/admin/app/oidc_client/instance/0oafd3emm2kkSKUAX5d7#tab-general)

---

<div class="post-metadata">

**Author:** ![harishdalmia](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@harishdalmia](https://devforum.okta.com/u/harishdalmia)\
**Post date:** [February 27, 2024, 12:13am UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/5 "2024-02-27T00:13:50Z")

</div>

Also after logging, i am getting the code in the browser but while using it, fails. same error

---

<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:** [February 27, 2024, 7:12pm UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/6 "2024-02-27T19:12:03Z")

</div>

Hi @harishdalmia, thanks for sharing your sign-in link. Looks like you are requesting a code from the Okta Org Authorization Server - [https://dev-10159567.okta.com](https://dev-10159567.okta.com/.well-known/openid-configuration) instead of the Default Authorization Server that you mentioned ([https://dev-10159567.okta.com/oauth2/default](https://dev-10159567.okta.com/oauth2/default/.well-known/openid-configuration)), when you initiated this post. Read about the differences here - [Authorization servers | Okta Developer](https://developer.okta.com/docs/concepts/auth-servers/#available-authorization-server-types). The code will be considered invalid if you present it to the wrong authorization server’s token endpoint. Please confirm this is not the case. Also, I discuss common pitfalls with authorization servers here - [https://www.youtube.com/watch?v=PASiA\_2ChFU](https://www.youtube.com/watch?v=PASiA_2ChFU). Please let me know if this helps.

---

<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 28, 2024, 7:12pm UTC](https://devforum.okta.com/t/fetching-the-user-token/26995/7 "2024-02-28T19:12:22Z")

</div>

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