Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/oauth2_server/authorization_server.ts>AuthorizationServer

A standards compliant implementation of an OAuth 2.0 authorization server with PKCE support.
Latest
class AuthorizationServer
import { AuthorizationServer } from "https://deno.land/x/oauth2_server@0.12.0/authorization_server.ts";

Constructors

new
AuthorizationServer(options: AuthorizationServerOptions<Client, User, Scope>)

Type Parameters

Client extends ClientInterface
User
optional
Scope extends ScopeInterface = DefaultScope

Methods

authorize<Request extends OAuth2Request<Client, User, Scope>, AuthorizeRequest extends OAuth2AuthorizeRequest<Client, User, Scope>, Response extends OAuth2Response>(
request: Request,
response: Response,
setAuthorization: (request: AuthorizeRequest) => Promise<void>,
login: (request: AuthorizeRequest, response: Response) => Promise<void>,
consent?: (request: AuthorizeRequest, response: Response) => Promise<void>,
): Promise<void>

Authorizes a token request for the authorization code grant type.

authorizeError<Request extends OAuth2Request<Client, User, Scope>, AuthorizeRequest extends OAuth2AuthorizeRequest<Client, User, Scope>, Response extends OAuth2Response>(
request: Request,
response: Response,
error: OAuth2Error,
login: (request: AuthorizeRequest, response: Response) => Promise<void>,
consent?: (request: AuthorizeRequest, response: Response) => Promise<void>,
): Promise<void>

Handles the response for an unauthorized request.

authorizeSuccess<Request extends OAuth2AuthorizedRequest<Client, User, Scope>, Response extends OAuth2Response>(request: Request, response: Response): Promise<void>

Handles the response for an authorization request.

Generates a bearer token from a token.

token(request: OAuth2Request<Client, User, Scope>, response: OAuth2Response): Promise<void>

Handles a token request.

tokenError(): Promise<void>

Handles the response for an unsuccessful token request.

tokenResponse(_request: OAuth2Request<Client, User, Scope>, response: OAuth2Response): Promise<void>

Adds headers to the token response.

Handles the response for a successful token request.