Skip to main content
Module

x/deno_kv_oauth/mod.ts>signIn

High-level OAuth 2.0 powered by Deno KV.
Go to Latest
function signIn
import { signIn } from "https://deno.land/x/deno_kv_oauth@v0.2.7/mod.ts";

Handles the sign-in process for a given OAuth 2.0 client and redirects the client to the authorization URL.

It does this by:

  1. Using a randomly generated state to construct the OAuth 2.0 provider's authorization URL and code verifier.
  2. Storing an OAuth 2.0 session object that contains the state and code verifier in KV. The OAuth 2.0 session object will be used in the callback handler to get the OAuth 2.0 tokens from the given provider.
  3. Returning a response that sets the client's OAuth 2.0 session cookie and redirects the client to the OAuth 2.0 provider's authorization URL.

Examples

Example 1

import { signIn, createGitHubOAuth2Client } from "https://deno.land/x/deno_kv_oauth@$VERSION/mod.ts";

const oauth2Client = createGitHubOAuth2Client();

export async function handleSignIn(request: Request) {
 return await signIn(request, oauth2Client);
}

Parameters

request: Request

The HTTP request from the client.

oauth2Client: OAuth2Client