Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

AuthorizationCodeGrant

import { AuthorizationCodeGrant } from "https://raw.githubusercontent.com/cmd-johnson/deno-oauth2-client/master/mod.ts";

Implements the OAuth 2.0 authorization code grant.

See https://tools.ietf.org/html/rfc6749#section-4.1

class AuthorizationCodeGrant extends OAuth2GrantBase {
constructor(client: OAuth2Client);
private buildAccessTokenRequest(
code: string,
codeVerifier?: string,
requestOptions?: RequestOptions,
): Request;
private async validateAuthorizationResponse(url: URL, options: AuthorizationCodeTokenOptions): Promise<{
code: string;
state?: string;
}
>
;
public getAuthorizationUri(options?: AuthorizationUriOptionsWithPKCE): Promise<AuthorizationUriWithVerifier>;
public getAuthorizationUri(options: AuthorizationUriOptionsWithoutPKCE): Promise<AuthorizationUriWithoutVerifier>;
public async getAuthorizationUri(options?: AuthorizationUriOptions): Promise<AuthorizationUri>;
public async getToken(authResponseUri: string | URL, options?: AuthorizationCodeTokenOptions): Promise<Tokens>;
}

§Extends

§
OAuth2GrantBase
[src]

§Constructors

§
new AuthorizationCodeGrant(client: OAuth2Client)
[src]

§Methods

§
buildAccessTokenRequest(code: string, codeVerifier?: string, requestOptions?: RequestOptions): Request private
[src]
§
validateAuthorizationResponse(url: URL, options: AuthorizationCodeTokenOptions): Promise<{
code: string;
state?: string;
}
>
private
[src]
§
getAuthorizationUri(options?: AuthorizationUriOptionsWithPKCE): Promise<AuthorizationUriWithVerifier>
[src]

Builds a URI you can redirect a user to to make the authorization request.

By default, PKCE will be used. You can opt out of PKCE by passing { disablePkce: true } in the options.

When using PKCE it is your responsibility to store the returned codeVerifier and associate it with the user's session just like with the state parameter. You have to pass it to the getToken() request when you receive the authorization callback or the token request will fail.

getAuthorizationUri(options: AuthorizationUriOptionsWithoutPKCE): Promise<AuthorizationUriWithoutVerifier>
[src]
getAuthorizationUri(options?: AuthorizationUriOptions): Promise<AuthorizationUri>
[src]
§
getToken(authResponseUri: string | URL, options?: AuthorizationCodeTokenOptions): Promise<Tokens>
[src]

Parses the authorization response request tokens from the authorization server.

Usually you'd want to call this method in the function that handles the user's request to your configured redirectUri.

@param authResponseUri

The complete URI the user got redirected to by the authorization server after making the authorization request. Must include all received URL parameters.