Developer Preview — This project is in active development. APIs may change. Provide feedback
Skip to content

Auth Commands

Commands for authentication and token management.

b2c auth token

Get an OAuth access token for use in scripts or other tools.

Usage

bash
b2c auth token

Flags

FlagEnvironment VariableDescription
--client-idSFCC_CLIENT_IDClient ID for OAuth
--client-secretSFCC_CLIENT_SECRETClient Secret for OAuth
--scopeSFCC_OAUTH_SCOPESOAuth scopes to request (can be repeated)
--account-manager-hostSFCC_ACCOUNT_MANAGER_HOSTAccount Manager hostname (default: account.demandware.com)

Examples

bash
# Get a token with default scopes
b2c auth token --client-id xxx --client-secret yyy

# Get a token with specific scopes
b2c auth token --scope sfcc.orders --scope sfcc.products

# Output as JSON (useful for parsing)
b2c auth token --json

# Using environment variables
export SFCC_CLIENT_ID=my-client
export SFCC_CLIENT_SECRET=my-secret
b2c auth token

Output

The command outputs the access token:

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

With --json:

json
{"token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...","expires_in":1799}

Use Cases

Scripting

Use the token in shell scripts:

bash
TOKEN=$(b2c auth token)
curl -H "Authorization: Bearer $TOKEN" https://my-instance.demandware.net/s/-/dw/data/v24_3/sites

CI/CD Pipelines

Get a token for use with other tools:

bash
export SFCC_TOKEN=$(b2c auth token --json | jq -r '.token')

Testing API Calls

Quickly get a token for testing OCAPI or SCAPI:

bash
b2c auth token | pbcopy  # macOS: copy to clipboard

Authentication Overview

For complete authentication setup instructions, see the Authentication Setup Guide.

Quick Reference

OperationAuth Required
Code deploy/watchWebDAV credentials
Code list/activate/delete, Jobs, SitesOAuth + OCAPI configuration
SCAPI commands (eCDN, schemas, custom-apis)OAuth + SCAPI scopes
Sandbox, SLASOAuth + appropriate roles
MRTAPI Key

See Configuration for setting up credentials via environment variables or config files.

TIP

Each command page below documents its specific authentication requirements including required scopes.

Released under the Apache-2.0 License.