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