Table of Contents

Class Auth0WebAppWithAccessTokenEvents

Namespace
Auth0.AspNetCore.Authentication
Assembly
Auth0.AspNetCore.Authentication.dll

Events allowing you to hook into specific moments in the Auth0 middleware.

public class Auth0WebAppWithAccessTokenEvents
Inheritance
Auth0WebAppWithAccessTokenEvents
Inherited Members

Properties

OnMissingAccessToken

Executed when an Access Token is missing where one was expected, allowing you to react accordingly.

public Func<HttpContext, Task>? OnMissingAccessToken { get; set; }

Property Value

Func<HttpContext, Task>

Examples

services
  .AddAuth0WebAppAuthentication(options => {})
  .WithAccessToken(options =>
  {
      options.Events = new Auth0WebAppWithAccessTokenEvents
      {
          OnMissingAccessToken = async (context) =>
          {
              await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
              var authenticationProperties = new AuthenticationPropertiesBuilder().WithRedirectUri("/").Build();
              await context.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
          }
      };
  });

OnMissingRefreshToken

Executed when a Refresh Token is missing where one was expected, allowing you to react accordingly.

public Func<HttpContext, Task>? OnMissingRefreshToken { get; set; }

Property Value

Func<HttpContext, Task>

Examples

services
  .AddAuth0WebAppAuthentication(options => {})
  .WithAccessToken(options =>
  {
      options.Events = new Auth0WebAppWithAccessTokenEvents
      {
          OnMissingRefreshToken = async (context) =>
          {
              await context.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
              var authenticationProperties = new AuthenticationPropertiesBuilder().WithRedirectUri("/").Build();
              await context.ChallengeAsync(Auth0Constants.AuthenticationScheme, authenticationProperties);
          }
      };
  });