File: auth.nu 3 exported commands 0 internal commands

sf login

Log in to Salesforce and set $env.SALESFORCE.

The login method is chosen from the flags you provide:

Client Credentials (server-to-server, no user): sf login --client-id <id> --client-secret <secret> --instance mydomain.my.salesforce.com

JWT Bearer (server-to-server, authenticates as a user via an RSA key): sf login --client-id <id> --username user@example.com --jwt-key ./server.key

Device (interactive login from a headless terminal): sf login --device --client-id <id> # confidential client (app requires a secret): sf login --device --client-id <id> --client-secret <secret>

Direct session ID: sf login --session-id <token> --instance mydomain.my.salesforce.com

SOAP username/password (DEPRECATED — retires June 1, 2027): sf login --username user@example.com --password XXXX --token XXXX

Usage

sf login --client-id <string> --client-secret <string> --jwt-key <path> --scope <string> --username <string> --password <string> --token <string> --session-id <string> --instance <string> --domain <string> --version <string> [--device]

Flags

--client-id <string>
OAuth consumer key from the External Client App
--client-secret <string>
OAuth consumer secret (Client Credentials flow)
--jwt-key <path>
Path to the RSA private key for the JWT Bearer flow
--scope <string>
OAuth scopes to request (Device flow)
--username <string>
Salesforce username (JWT Bearer sub, or SOAP login)
--password <string>
Password (SOAP login only)
--token <string>
Security token (SOAP login only)
--session-id <string>
Direct access token (alternative to a flow)
--instance <string>
My Domain host of your org (mydomain.my.salesforce.com)
--domain <string>
Login domain for login.salesforce.com endpoints: "login" (production) or "test" (sandbox). Default: "login"
--version <string>
Salesforce API version. Default: "64.0"
--device
Use the OAuth Device flow (interactive browser approval)

Input/output types

inputoutput
anyany

Examples

Client Credentials flow

sf login --client-id $env.SF_CLIENT_ID --client-secret $env.SF_CLIENT_SECRET --instance "mydomain.my.salesforce.com"

JWT Bearer flow

sf login --client-id $env.SF_CLIENT_ID --username "user@example.com" --jwt-key "./server.key"

Device flow

sf login --device --client-id $env.SF_CLIENT_ID

sf logout

Clear the Salesforce session.

Usage

sf logout

Input/output types

inputoutput
anyany

sf whoami

Show current Salesforce session information.

Usage

sf whoami

Input/output types

inputoutput
anyany