Salesforce OAuth provider

OAuth 2.0 (Authorization code) integration for Salesforce. Provider id is salesforce.

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

const salesforceAuth = salesforce(auth, configs);

salesforce()#

Scopes oidc, profile, and id are always included.

const salesforce: (
	auth: Auth,
	configs: {
		clientId: string;
		clientSecret: string;
		redirectUri: string;
		scope?: string[];
	}
) => SalesforceProvider;
Parameters#
nametypedescriptionoptional
authAuthLucia instance
config.clientIdstringSalesforce OAuth app client id
config.clientSecretstringSalesforce OAuth app client secret
config.redirectUristringan authorized redirect URI
config.scopestring[]an array of scopes
Returns#
typedescription
SalesforceProviderSalesforce provider

Interfaces#

SalesforceAuth#

See OAuth2ProviderAuth.

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

SalesforceTokens#

type SalesforceTokens = {
	accessToken: string;
	idToken: string;
	refreshToken: string | null;
};

SalesforceUser#

type SalesforceUser = {
	sub: string; // URL
	user_id: string;
	organization_id: string;
	name: string;
	email?: string;
	email_verified: boolean;
	given_name: string;
	family_name: string;
	zoneinfo: string;
	photos: {
		picture: string;
		thumbnail: string;
	};
	profile: string;
	picture: string;
	address?: Record<string, string>;
	urls: Record<string, string>;
	active: boolean;
	user_type: string;
	language: string;
	locale: string;
	utcOffset: number;
	updated_at: string;
};

SalesforceUserAuth#

Extends ProviderUserAuth.

interface SalesforceUserAuth<_Auth extends Auth>
	extends ProviderUserAuth<_Auth> {
	salesforceUser: SalesforceUser;
	salesforceTokens: SalesforceTokens;
}
propertiestypedescription
salesforceUserSalesforceUserSalesforce user
salesforceTokensSalesforceTokensAccess tokens etc
Generics#
nameextends
_AuthAuth