Hi!
I tryin to setup Auth0 for my Optimizely net core 6 application but I cannot get the redirect_uri to change.
I’m using ngrok to translate https://localhost:61011 to https://bcf-krilin.ngrok.io and when doing the login i set the redirect url to https://bcf-krilin.ngrok.io/
[HttpGet]
public async Task Login(IContent node, string returnUrl)
{
var url = node == null ? "/" : UrlResolver.Current.GetUrl(node.ContentLink);
if (!string.IsNullOrWhiteSpace(returnUrl))
{
url = returnUrl;
}
#if DEBUG
url = _configuration.GetValue<string>("Auth0RedirectUri");
#endif
var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
// Indicate here where Auth0 should redirect the user after a login.
// Note that the resulting absolute Uri must be added to the
// **Allowed Callback URLs** settings for the app.
.WithRedirectUri(url)
.Build();
await HttpContext.ChallengeAsync(
Auth0Constants.AuthenticationScheme,
authenticationProperties
);
}
This is how my Startup.cs looks like:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = Auth0Constants.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(Auth0Constants.AuthenticationScheme, options => {
// Set the authority to your Auth0 domain
options.Authority = $"https://{domain}";
// Configure the Auth0 Client ID and Client Secret
options.ClientId = clientId;
options.ClientSecret = clientSecret;
options.SignedOutRedirectUri = postLogout;
// Set response type to code
options.ResponseType = OpenIdConnectResponseType.Code;
// Configure the scope
options.Scope.Clear();
options.Scope.Add(OidcConstants.StandardScopes.OpenId);
// Set the callback path, so Auth0 will call back to http://localhost:3000/callback
// Also ensure that you have added the URL as an Allowed Callback URL in your Auth0 dashboard
options.CallbackPath = new PathString("/callback");
// Configure the Claims Issuer to be Auth0
options.ClaimsIssuer = Auth0Constants.AuthenticationScheme;
});
The return_url looks like this:
redirect_uri=https%3A%2F%2Flocalhost%3A61011%2Fcallback
How do I change base url? The options.Callback must start with a /
Thanks!
/Kristoffer