b2c-slas について
b2c-slasは、`b2c` コマンドラインでSLASの顧客認証クライアントと認証情報を管理するためのスキルです。店舗、ヘッドレスコマース、APIテスト向けに、クライアント操作と顧客トークン取得を扱います。
主な機能
- 01SLASクライアントの一覧と詳細確認
- 02クライアントの作成・更新・削除
- 03スコープとリダイレクト先の設定
- 04顧客アクセストークンの取得
- 05CLI設定からの値の解決
活用シーン
- 01コンポーザブルストアフロント用クライアントの設定
- 02カスタムスコープを使ったCustom APIのテスト
- 03専用の統合テストクライアントの作成
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ salesforcecommercecloud/ b2c-developer-tooling --skill b2c-slasインストール後、Claude Code で/b2c-slasを入力して読み込まれたか確認します。
同梱ファイルevals/trigger-evals.json
詳細
B2C SLAS スキル
b2c CLI プラグインを使用して、SLAS(Shopper Login and API Access Service)の API クライアントと認証情報を管理します。
重要: SLAS は、ストアフロントやヘッドレスコマースで使用するショッパー(顧客)認証向けです。管理者トークン(OCAPI、Admin API)には、
b2c auth tokenを使用してください。詳しくは、b2c-configスキルをご覧ください。
ヒント:
b2cがグローバルにインストールされていない場合は、代わりにnpx @salesforce/b2c-cliを使用してください(例:npx @salesforce/b2c-cli slas client list)。
設定
tenantId、shortCode、slasClientId、slasClientSecret などの値は、dw.json、SFCC_* 環境変数、アクティブなインスタンス、または設定プラグインから解決されます。以下の例では最小限の使用方法を示しています。設定済みの値を上書きする場合にのみ、フラグを追加してください。通常、これらをフラグとして渡す必要はありません。必須の値が不足している場合、CLI はフラグ、環境変数、設定キーを示す、対処方法が明確なエラーを出力します。
b2c setup inspect を実行すると、解決された設定と各値の取得元を確認できます(スクリプトで使用する場合は --json を指定してください。シークレットはデフォルトでマスクされます)。優先順位のルールとトラブルシューティングについては、b2c-cli:b2c-config スキルをご覧ください。
関連する上書き設定:
--tenant-id/SFCC_TENANT_ID/tenantId--short-code/SFCC_SHORTCODE/shortCode--slas-client-id/SFCC_SLAS_CLIENT_ID/slasClientId--slas-client-secret/SFCC_SLAS_CLIENT_SECRET/slasClientSecret
既存のクライアントを対象とするコマンド(get、update、delete、open)では、位置引数のクライアント ID を省略すると、設定済みの slasClientId が使用されます。位置引数で指定したクライアント ID は、設定より優先されます。
使用する場面
SLAS クライアントの管理が必要となる一般的なシナリオ:
- カスタム API のテスト:カスタムスコープ(例:
c_loyalty)を持つクライアントを作成し、カスタム API エンドポイントをテストします - PWA/ヘッドレス開発:コンポーザブルストアフロント用のクライアントを設定します
- 統合テスト:特定のスコープセットを持つ専用のテストクライアントを作成します
例
SLAS クライアントの一覧表示
# list all SLAS clients for the configured tenant
b2c slas client list
# JSON output
b2c slas client list --json
# target a different tenant than the active config
b2c slas client list --tenant-id abcd_123
SLAS クライアントの詳細取得
# get details for the configured SLAS client
b2c slas client get
# override the configured client ID
b2c slas client get my-client-id
SLAS クライアントの作成
# create a new SLAS client with default scopes (auto-generates UUID client ID)
b2c slas client create --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback
# create with a specific client ID and custom scopes
b2c slas client create my-client-id --channels RefArch --scopes sfcc.shopper-products,sfcc.shopper-search --redirect-uri http://localhost:3000/callback
# create a public client
b2c slas client create --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --public
# create client without auto-creating tenant (if you manage tenants separately)
b2c slas client create --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --no-create-tenant
# output as JSON (useful for capturing the generated secret)
b2c slas client create --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --json
注:デフォルトでは、テナントが存在しない場合に自動的に作成されます。
警告: クライアントのスコープには --scopes(複数形)を使用してください。--auth-scope(単数形)は使用しないでください。--auth-scope フラグは、OAuth スコープ用のグローバルな認証オプションです。
カスタム API のテスト用クライアントの作成
カスタムスコープが必要なカスタム API をテストする場合:
# Create a private client with custom scope for testing
# Replace c_my_scope with your API's custom scope from schema.yaml
b2c slas client create \
--channels RefArch \
--default-scopes \
--scopes "c_my_scope" \
--redirect-uri http://localhost:3000/callback \
--json
# Output includes client_id and client_secret - save these for token requests
重要: SLAS クライアントのカスタムスコープは、カスタム API の schema.yaml のセキュリティセクションで定義されているスコープと一致している必要があります。
ショッパートークンの取得
API テスト用のショッパーアクセストークンを取得するには、b2c slas token を使用します。--site-id はリクエスト固有のため、呼び出しごとに指定する必要があります。
このコマンドは、SFCC_EXTRA_HEADERS(JSON オブジェクト)または --extra-headers のヘッダーを含む、共通 HTTP ミドルウェアを認証、ログイン、トークンの各リクエストに適用します。
JSON 出力では、トークンのフィールドは response の下に格納されます(例:.response.accessToken)。
認証に失敗した場合は、--log-level debug を使用して、HTTP ステータスと SLAS レスポンスの相関 ID を取得してください。
# Guest token with auto-discovery (finds first public SLAS client)
b2c slas token --site-id RefArch
# Registered customer token
b2c slas token --site-id RefArch --shopper-login [email protected] --shopper-password secret
# JSON output (includes refresh token, expiry, usid, etc.)
b2c slas token --site-id RefArch --json
# Use token in a subsequent API call
TOKEN=$(b2c slas token --site-id RefArch)
curl -H "Authorization: Bearer $TOKEN" "https://$SHORTCODE.api.commercecloud.salesforce.com/..."
# Override the SLAS client explicitly (e.g., targeting a private client for client_credentials flow)
b2c slas token --site-id RefArch --slas-client-id my-client --slas-client-secret sk_xxx
# Registered customer token against a private client (registered login is always PKCE-protected;
# the client secret is sent as Basic auth in addition to the PKCE code_verifier)
b2c slas token --site-id RefArch --slas-client-id my-client --slas-client-secret sk_xxx \
--shopper-login [email protected] --shopper-password secret
SLAS クライアントの更新
# update the configured client's display name
b2c slas client update --name "New Name"
# override the configured client ID and rotate its secret
b2c slas client update my-client-id --secret new-secret-value
# add scopes (appends to existing by default)
b2c slas client update my-client-id --scopes sfcc.shopper-baskets
# replace scopes instead of appending
b2c slas client update my-client-id --scopes sfcc.shopper-baskets --replace
# replace channels
b2c slas client update my-client-id --channels RefArch,SiteGenesis --replace
SLAS クライアントの削除
# delete the configured SLAS client
b2c slas client delete
# override the configured client ID
b2c slas client delete my-client-id
SLAS クライアントを開く
# open the configured SLAS client in the Admin UI
b2c slas client open
# override the configured client ID
b2c slas client open my-client-id
その他のコマンド
slas トピックで使用できるコマンドとオプションの全一覧については、b2c slas --help をご覧ください。
関連スキル
b2c:b2c-custom-api-development- SLAS 認証が必要なカスタム API の作成b2c-cli:b2c-scapi-custom- カスタム API の登録ステータスの確認