The redirect URI specified in the request does not match the redirect URIs configured for the application

Jack Kelly 31 Reputation points
2022-07-26T21:52:12.877+00:00

I am creating an app using Python (Flask) and followed this tutorial: https://learn.microsoft.com/en-us/azure/active-directory/develop/web-app-quickstart?pivots=devlang-python

When I run I get the following error: AADSTS50011: The redirect URI 'http://127.0.0.1:5000/getAToken' specified in the request does not match the redirect URIs configured for the application

The redirect URI that I specified in Azure per the tutorials instructions is http://localhost:5000/getAToken

The app is running locally on http://127.0.0.1:5000

So the URIs absolutely match. Why am I still getting this error?

Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} vote

Accepted answer
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2022-07-26T22:37:40.887+00:00

    Hi @Jack Kelly ,

    It sounds like you are accessing the the application using the http://127.0.0.1:5000 in the browser, so your redirect URI is getting changed to http://127.0.0.1:5000/getAToken . Since this entry does not exist in your Redirect URI configuration in the Azure AD App Registration, you are receiving the reply URL mismatch error.

    There are a few things that should work to resolve this:

    1) Access the application using http://localhost:5000

    2) Force the host to be localhost at the application startup.

     if __name__ == "__main__":  
         app.run(host="localhost")  
    

    3) Change the reply url configured In the authentication tab of the app registration to http://127.0.0.1:5000/getAToken

    If these solutions do not work, feel free to reach out to me over email and I will gladly help troubleshoot. There was a thread here where a user was having a similar issue with the absolute URL in the Python sample.

    -
    If the information provided was helpful to you, please remember to "mark as answer" so that others in the community with similar questions can more easily find a solution.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.