Hi MuhammedIsmailMannilthodi-0476,
I understand that you are receiving a reply URL mismatch error, even though the reply URL in your request matches the one in your app registration. There are a few issues that could cause this.
For local testing, note that when you try to use an http scheme, the port component (for example, :5001 or :443) is ignored for the purposes of matching a redirect URI. As a result, all of these URIs are deemed equivalent. For example, if you have more than one redirect uri for different purposes (example: http://localhost:5000/mywebapp and http://localhost:5001/mywebapp), both are considered equivalent. So for the most part, the redirect URL for web apps and services must begin with the scheme https
. See: Redirect URI (reply URL) restrictions and limitations
If the URLs match, it is possible that the proxy is terminating HTTPS, so the traffic your application is getting is HTTP. If this is the case, you will need to update the proxy to forward the headers and add Https redirection.
See example code:
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedProto
});
Then adding this reference:
using Microsoft.AspNetCore.HttpOverrides;
You may need to also ensure that you have set ASPNETCORE_FORWARDEDHEADERS_ENABLED=true in the application settings.
If the issues is not related to HTTP/HTTPS mismatch, please also verify that login.microsoft.com is added to the allowed CORS list, and that none of the reply URLs have any extra spaces, slashes, or additional characters.
If the suggestions do not work, feel free to reach out to me at AzCommunity@microsoft.com ("Attn: Marilee Turscak") and include your subscription ID, a link to this post, a screenshot of your full error message and redirect URI configuration in the portal, and I will gladly assist.
Additional resources:
Redirect URI (reply URL) restrictions and limitations
AADSTS500112: The reply address 'http://testurl' does not match
How to set redirect_uri protocol to HTTPS in Azure Web Apps
Reply URL mismatch
AADSTS500112: The reply address does not match the reply address provided when requesting Authorization code
Reply address does not match
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 information.