Redirect URI is not returning "code" as it is supposed to.

Apps Sandbox 0 Reputation points
2023-02-03T09:53:18.4633333+00:00

The "https://login.microsoftonline.com/common/oauth2/v2.0/authorize" endpoint is used to initiate the OAuth 2.0 authorization code flow for authenticating and obtaining an access token from Azure Active Directory (AAD).

When this endpoint is called, it redirects the user to the AAD login page, where the user can enter their credentials and consent to the requested permissions. After successful authentication, AAD will redirect the user back to the redirect URI specified in the initial request, along with an authorization code in the query string. But in our case, sometimes we do not receive "code" along with redirect URI in the query string.

Could you please let us know what could be causing the issue here?

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,473 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Marilee Turscak-MSFT 33,801 Reputation points Microsoft Employee
    2023-02-03T19:51:44.2566667+00:00

    Hi Apps Sandbox ,

    Since you are using the OAuth 2.0 authorization code flow, it's possible that your issue could be related to the "follow redirects" setting. If you are receiving a 200 instead of a 302 in the response code, verify if there's a configuration to set "follow redirects" to true (possibly in your forward-request policy). If so, change it to false and see if you receive the code in the header.

    Also, while it won't provide the exact resolution, you can use the OIDC debugger playground to validate your configuration - OIDC Debugger

    See related thread:

    Not getting a code on the redirect url

    Let me know if this helps. I'm happy to keep troubleshooting if your issue turns out to be something different. It would help if you include your full request in this post.

    -

    If the information helped you, please Accept the answer. This will help us as well as others in the community who might be researching similar questions.

    0 comments No comments