Kysoql
Authentication flows

Authentication flow guide

Choose the Salesforce authentication flow that fits a REST and SOQL integration.

@kysoql/auth covers the supported Salesforce OAuth and assertion flows that can produce bearer sessions for REST API use. The SalesforceAuth class is the primary application-facing API: configure the Salesforce URL and client ID once, then choose the flow through a method. Start with JWT bearer for a typical certificate-backed server-to-server integration, then choose another flow only when the application architecture requires it.

FlowTypical useKysoql guide
JWT bearerServer-to-server with an integration user and private keyJWT bearer
Web-server + PKCEUser-facing web applicationWeb-server + PKCE
Refresh tokenRenew an authorized user sessionRefresh token
Client credentialsServer-to-server with client ID/secret and configured integration userClient credentials
private_key_jwtAuthenticate a confidential OAuth client at supported token endpointsPrivate-key client authentication
SAML bearerExchange a signed SAML 2.0 bearer assertionSAML bearer
SAML assertionFederate to the Salesforce API using the SAML assertion API flowSAML assertion
Token exchangeExchange a token from an identity provider for a Salesforce tokenToken exchange
DeviceCLI or constrained-input device authorizationDevice flow
Hybrid web-serverHybrid apps that need Salesforce web-session bridgingHybrid web-server
Hybrid refreshRenew a hybrid app session and web-session SIDsHybrid refresh
Authorization Code and CredentialsHeadless Experience Cloud named-user or discovered-user loginCode and Credentials
Headless guestExperience Cloud guest authorization with UVID contextHeadless guest
First-party username-passwordFirst-party headless login for private Experience Cloud clientsUsername-password
First-party passwordlessEmail/SMS OTP login for private Experience Cloud clientsPasswordless
First-party registrationHeadless registration and OTP verificationRegistration

Common behavior

Token-endpoint helpers validate HTTPS Salesforce URLs, send form-encoded POST requests where Salesforce requires them, reject redirects, enforce bounded request timeouts, and validate bearer-token responses.

OAuth HTTP failures throw SalesforceOAuthError, exposing the HTTP status and OAuth error code. Malformed successful responses throw SalesforceOAuthResponseError.

For REST API usage, pass the returned instanceUrl and accessToken to @kysoql/rest. Salesforce REST API accepts OAuth bearer tokens in the Authorization header.

On this page