Legacy Dev Forum Posts

 View Only

Sign Up

OAuth token endpoint failure

  • 1.  OAuth token endpoint failure

    Posted 06-05-2025 18:23

    Nandkishor_Yadav | 2022-08-12 12:19:01 UTC | #1

    Hi, I am using Grant - Authorization Code to authenticate ASP.NET Core app to get the list of emails and their attachments. The user is redirected to login page and after entering credentials, it is redirected back to my redirect URL with code and state (https://example.ie/home/index?code=xxxxxxx&state=xxxxxx).

    I guess the error happens when Exchanging Authorization Code for Access Token

    OAuth token endpoint failure: Status: BadRequest;Headers: Date: Fri, 12 Aug 2022 12:07:45 GMTConnection: keep-aliveInin-Correlation-Id: e0dc9a2c-60d1-4e1a-41ba-900dc2579fa4Strict-Transport-Security: max-age=7776000Vary: Accept-Encoding;Body: {"error":"accessdenied","description":"could not authorize","errordescription":"could not authorize"};

    The app works fine in DEV org(no ip restrictions), but I get above error in PRD org. There are IP restrictions in PRD org. I tried adding the public IP of the server where my app is hosted, but not able to fix the issues.

    Can you give me some pointers where might be the issue?

    thank you


    tim.smith | 2022-08-12 13:18:21 UTC | #2

    You are correct that IP restrictions are preventing authorization for that request. Please validate the requester's IP address and ensure that your IP allowlist config allows that address.


    Nandkishor_Yadav | 2022-08-12 14:41:21 UTC | #3

    Hi @tim.smith , After adding the IPs to allowlist, now I am getting this error: "Response status code does not indicate success: 401 (Unauthorized)." Can you please help on this?

    Thank you.


    tim.smith | 2022-08-12 20:09:18 UTC | #4

    A 401 response means that the auth token used in the request isn't valid.


    Nandkishor_Yadav | 2022-08-14 20:08:32 UTC | #5

    The error occurred when Exchanging Authorization Code for Access Token, so the app didn't even got the access token successfully (which will be used to make request to conversation API). The PRD org has SSO configured. I am getting the same error when logging in via SSO or without SSO. Can you tell me what went wrong?


    Nandkishor_Yadav | 2022-08-15 11:35:50 UTC | #6

    Issue is resolved now. Thank you


    John_Carnell | 2022-09-06 17:37:34 UTC | #7


    This post was migrated from the old Developer Forum.

    ref: 15863