Facebook OAuth provider

OAuth integration for Facebook. Refer to step 1 of Facebook Login documentation for getting the required credentials. Provider id is facebook.

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

const facebookAuth = facebook(auth, config);

The identity scope is always included regardless of provided scope config.

facebook()#

const facebook: (
	auth: Auth,
	config: {
		clientId: string;
		clientSecret: string;
		redirectUri: string;
		scope?: string[];
	}
) => FacebookProvider;
Parameters#

Scope identity is always included.

nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringFacebook OAuth app client id
config.clientSecretstringFacebook OAuth app client secret
config.redirectUristringan authorized redirect URI
config.scopestring[]an array of scopes
Returns#
typedescription
FacebookProviderFacebook provider

Interfaces#

FacebookAuth#

See OAuth2ProviderAuth.

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

FacebookTokens#

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

FacebookUser#

email is only included if email scope if provided.

type FacebookUser = {
	id: string;
	name: string;
	email?: string;
	picture: {
		data: {
			height: number;
			is_silhouette: boolean;
			url: string;
			width: number;
		};
	};
};

FacebookUserAuth#

Extends ProviderUserAuth.

interface FacebookUserAuth<_Auth extends Auth> extends ProviderUserAuth<_Auth> {
	facebookUser: FacebookUser;
	facebookTokens: FacebookTokens;
}
propertiestypedescription
facebookUserFacebookUserFacebook user
facebookTokensFacebookTokensAccess tokens etc
Generics#
nameextends
_AuthAuth