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#
| name | type | description | optional | 
|---|
| auth | Auth | Lucia instance |  | 
| config.clientId | string | Twitch OAuth app client id |  | 
| config.clientSecret | string | Twitch OAuth app client secret |  | 
| config.redirectUri | string | one of the authorized redirect URIs |  | 
| config.scope | string[] | an array of scopes | ✓ | 
 
Returns#
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#
| name | extends | default | 
|---|
| _Auth | Auth | Auth | 
 
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;
}
Generics#