Class OAuth2Strategy<User, Profile, ExtraParams>

Type Parameters

Hierarchy

Constructors

Properties

name: string = "oauth2"

The name of the strategy. This will be used by the Authenticator to identify and retrieve the strategy.

sessionCodeVerifierKey: string = "oauth2:codeVerifier"
sessionStateKey: string = "oauth2:state"
verify: StrategyVerifyCallback<User, OAuth2StrategyVerifyParams<Profile, ExtraParams>>

Methods

  • The authentication flow of the strategy.

    This method receives the Request to authenticator and the session storage to use from the Authenticator. It may receive a custom callback.

    At the end of the flow, it will return a Response to be used by the application.

    Parameters

    • request: Request
    • sessionStorage: SessionStorage<SessionData, SessionData>
    • options: AuthenticateOptions

    Returns Promise<User>

  • Return extra parameters to be included in the authorization request.

    Some OAuth 2.0 providers allow additional, non-standard parameters to be included when requesting authorization. Since these parameters are not standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication strategies can override this function in order to populate these parameters as required by the provider.

    Parameters

    Returns URLSearchParams

  • Throw an AuthorizationError or a redirect to the failureRedirect.

    Parameters

    • message: string

      The error message to set in the session.

    • request: Request

      The request to get the cookie out of.

    • sessionStorage: SessionStorage<SessionData, SessionData>

      The session storage to retrieve the session from.

    • options: AuthenticateOptions

      The strategy options.

    • Optionalcause: Error

    Returns Promise<never>

    If the throwOnError is set to true.

    If the failureRedirect is set or throwOnError is false.

  • Parameters

    • token: string
    • options: {
          signal?: AbortSignal;
          tokenType?: "access_token" | "refresh_token";
      } = {}
      • Optionalsignal?: AbortSignal
      • OptionaltokenType?: "access_token" | "refresh_token"

    Returns Promise<void>

  • Returns the user data or throw a redirect to the successRedirect.

    Parameters

    • user: User

      The user data to set in the session.

    • request: Request

      The request to get the cookie out of.

    • sessionStorage: SessionStorage<SessionData, SessionData>

      The session storage to retrieve the session from.

    • options: AuthenticateOptions

      The strategy options.

    Returns Promise<User>

    The user data.

    If the successRedirect is set, it will redirect to it.