ASP.NET Core incorrect redirect url

Hello.

I uses auth0 to connect to my application.
It works well localy but when i try to use it from the web I have a problem.

I uses the ASP.Net Core sample provided in the documentation (Auth0 ASP.NET Core MVC SDK Quickstarts: Login), and I have configured the login, logout, and the callBack URL properly in auth0.
My problem is that when I access to my service by is public adress and I hit the Login button, the url constructed by the service to call auth0.com indicates the local address in the “redirect_uri” section and not the public one.
Of course, this didn’t work because the local address isn’t globaly accessible…

My question is : where and how can I specified the right URL to use in the service ?

Any help greatly appreciated, thanks !

Hi @simonids,

Can you give us an example of the behavior? Screenshots may be helpful.

Hi,

First of all, thanks for your answer.

Here is a screenshot of my service based on the example from auth0 documentation. It runs on a IIS server, and is accessible from a public domain name (wich I overwrite here for confidentiality raisons).

The problem is, when you use the Login/Connexion button, the URL that is automatically built is like this : https://XYZ.auth0.com/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2F**MY_LOCAL_IP_ADDRESS_AND_PORT**%2Fcallback&…
And I need it to be like that to be ok : https://XYZ.auth0.com/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2F**MY_PUBLIC_DOMAIN_NAME.com**%2Fcallback&…

Thanks.

How are you setting your redirect URI? This should be a parameter you send with your request to the /authorize endpoint, and can be configured to whatever you prefer.

Showing us a code sample of your Auth0 implementation could help.

Hi,

The problem is I don’t set it : it’s set automatically by the Web Service.
My application is 98% like the sample app proposed on the help (Auth0 ASP.NET Core MVC SDK Quickstarts: Login) but to be sure I do nothing wrong I just send you by private message my code.
As you will see, I never set the redirect URL, and therefore I have no idea how to do it to resolve my problem.

Thank you for your help.

Hmmm, that is a good question. I don’t have much .NET core experience. Let me reach out to the team and get an answer for you.

Thanks for your answer, so I’m waiting for the rest of the team :wink:

Here was the response from one of our engineers:

This redirect URL is generated by the Microsoft.AspNetCore.Authentication.OpenIdConnect library used in .NET apps. Usually you’d want to have the redirect URL in the same domain as the app.
However, if the problem is that the app is not aware of the domain because the request come through a load balancer etc, they may need to use the x-forwarded-for headers nginx - AspNetCore Azure AD Connect Callback URL is http, not https - Stack Overflow

1 Like

Thank you and your team for your answer.
I’m currently checking the links you provide, and will come back to tell if I managed to resolve my problem.

1 Like

Problem solved !
In fact, it wasn’t a problem with the web service but a configuration on IIS that wasn’t correct… I found the solution thanks to the links you sent me, thanks a lot.

Great, thanks for the update! I am going to mark this one solved with the links for future users.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.