Twitch OAuth provider

OAuth integration for Twitch. Refer to Twitch OAuth documentation for getting the required credentials. Provider id is twitch.

import { twitch } from "@lucia-auth/oauth/providers";
import { auth } from "./lucia.js";

const twitchAuth = twitch(auth, configs);

twitch()#

const twitch: (
	auth: Auth,
	configs: {
		clientId: string;
		clientSecret: string;
		redirectUri: string;
		scope?: string[];
	}
) => TwitchProvider;
Parameters#
nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringTwitch OAuth app client id
config.clientSecretstringTwitch OAuth app client secret
config.redirectUristringone of the authorized redirect URIs
config.scopestring[]an array of scopes
Returns#
typedescription
TwitchProviderTwitch provider

Interfaces#

TwitchAuth#

See OAuth2ProviderAuth.

// implements OAuth2ProviderAuth<TwitchAuth<_Auth>>
interface TwitchAuth<_Auth extends Auth> {
	getAuthorizationUrl: () => Promise<readonly [url: URL, state: string]>;
	validateCallback: (code: string) => Promise<TwitchUserAuth<_Auth>>;
}
Generics#
nameextendsdefault
_AuthAuthAuth

TwitchTokens#

type TwitchTokens = {
	accessToken: string;
	refreshToken: string;
	accessTokenExpiresIn: number;
};

TwitchUser#

type TwitchUser = {
	id: string;
	login: string;
	display_name: string;
	type: "" | "admin" | "staff" | "global_mod";
	broadcaster_type: "" | "affiliate" | "partner";
	description: string;
	profile_image_url: string;
	offline_image_url: string;
	view_count: number;
	email?: string;
	created_at: string;
};

TwitchUserAuth#

Extends ProviderUserAuth.

interface TwitchUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	twitchUser: TwitchUser;
	twitchTokens: TwitchTokens;
}
propertiestypedescription
twitchUserTwitchUserTwitch user
twitchTokensTwitchTokensAccess tokens etc
Generics#
nameextends
_AuthAuth