I have a Blazor app and I have configured the Auth0 options in my Program.cs but what I need is to move that config out or Program.cs and do it in my controller class before the ChallengeAsync. Something like this:
[HttpGet]
public async Task ExternalLogin(string redirectUrl)
{
string callbackUrl = redirectUrl + “account/callback”;
var auth0Domain = configuration[“Auth0:Domain”];
var auth0ClientId = configuration[“Auth0:ClientId”];
var options = new OpenIdConnectOptions
{
ResponseType = “code”,
SaveTokens = true,
CallbackPath = new PathString(“/account/callback”),
Authority = $“https://{auth0Domain}”,
ClientId = auth0ClientId,
SkipUnrecognizedRequests = true
};
options.Scope.Clear();
options.Scope.Add(“openid”);
options.Scope.Add(“profile”);
options.Scope.Add(“email”);
var authenticationProperties = new LoginAuthenticationPropertiesBuilder()
.WithRedirectUri(callbackUrl)
.Build();
await HttpContext.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties, options);
}
The main idea is to change that config and no to have it static in my Program.cs.