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

x/oauth2_server/services/token.ts>TokenServiceInterface

A standards compliant implementation of an OAuth 2.0 authorization server with PKCE support.
Latest
interface TokenServiceInterface
import { type TokenServiceInterface } from "https://deno.land/x/oauth2_server@0.12.0/services/token.ts";

Type Parameters

Client extends ClientInterface
User
Scope extends ScopeInterface

Properties

accessTokenLifetime: number

Lifetime of access tokens in seconds.

refreshTokenLifetime: number

Lifetime of refresh tokens in seconds.

Methods

acceptedScope(
client: Client,
user: User,
scope?: Scope | null,
): Promise<
| null
| undefined
| false
>

Validates scope for a client and user.

generateAccessToken(
client: Client,
user: User,
scope?: Scope | null,
): Promise<string>

Generates an access token.

generateRefreshToken(
client: Client,
user: User,
scope?: Scope | null,
): Promise<string | undefined>

Generates a refresh token.

accessTokenExpiresAt(
client: Client,
user: User,
scope?: Scope | null,
): Promise<Date | undefined>

Gets the date that a new access token would expire at.

refreshTokenExpiresAt(
client: Client,
user: User,
scope?: Scope | null,
): Promise<Date | undefined>

Gets the date that a new refresh token would expire at.

getToken(accessToken: string): Promise<Token<Client, User, Scope> | undefined>

Retrieves an existing token by access token.

getRefreshToken(refreshToken: string): Promise<RefreshToken<Client, User, Scope> | undefined>

Retrieves an existing token by refresh token.

save(token: Token<Client, User, Scope>): Promise<Token<Client, User, Scope>>

Saves a token.

revoke(token: Token<Client, User, Scope>): Promise<boolean>

Revokes a token. Resolves true if a token was revoked or invalid.

revoke(token: string, hint?: string | null): Promise<boolean>
revokeCode(code: string): Promise<boolean>

Revokes all tokens for an authorization code. Resolves true if a authorization code was revoked or invalid.