redirect uri returns wrong uri

Søren Brønsted 21 Reputation points
2022-01-24T12:37:26.893+00:00

In Azure AD for out Company (borsen.dk)

on App > Authentication > Platform configurations > Web > Redirect URIs

I have configured 2 redirect uri for 2 different environments - test and production, but every time I login from the test environment the AAD redirects to the production environment even though the redirect url parameter is the url to the test environment. If I remove the production environment, it works.

Any explanation on this odd behavior?

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

2 answers

Sort by: Most helpful
  1. James Hamil 21,466 Reputation points Microsoft Employee
    2022-02-01T20:37:59.04+00:00

    Hi @Søren Brønsted ,

    I understand that you are being directed to the wrong URL. You need to specify the redirect URI in the login URL and specify where the user and authorization code should be redirected. If you don't specify a Redirect URI in the Login URL, the user will be redirected to the first URL specified in the app's registration.

    To resolve this, you can follow the example in the Authorization Code Grant Flow documentation to specify the Redirect URI:

    https://login.microsoftonline.com/{tenant}/oauth2/authorize?
    client_id=xxxxxx
    &response_type=code
    &redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
    &response_mode=query
    &resource=https%3A%2F%2Fservice.contoso.com%2F
    &state=12345

    Otherwise you could list the URL that you want as the first one in the registration.

    Let me know if you have further questions.

    Additional reading: https://stackoverflow.com/questions/46917919/azure-ad-reply-url-how-to-add-several-urls-when-using-openid-connect-auth


  2. Tatyana Kudryavtseva 0 Reputation points
    2023-10-12T19:08:03.5366667+00:00
    0 comments No comments