Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public void ConfigureServices(IServiceCollection services)
   // Add authentication services
   services.AddAuthentication(options => {
       options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
       options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
       options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
   .AddOpenIdConnect("Auth0", options => {
       // Set the authority to your Auth0 domain
       options.Authority = $"https://{Configuration["Auth0:Domain"]}";
       // Configure the Auth0 Client ID and Client Secret
       options.ClientId = Configuration["Auth0:ClientId"];
       options.ClientSecret = Configuration["Auth0:ClientSecret"];
       // Set response type to code
       options.ResponseType = "code";
       // Configure the scope
       // 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 = "Auth0";
   // Add framework services.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment