b2c-slas

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

B2C SLAS Skill

B2C SLAS 技能

Use the
b2c
CLI plugin to manage SLAS (Shopper Login and API Access Service) API clients and credentials.
Important: SLAS is for shopper (customer) authentication used by storefronts and headless commerce. For admin tokens (OCAPI, Admin APIs), use
b2c auth token
- see b2c-config skill.
Tip: If
b2c
is not installed globally, use
npx @salesforce/b2c-cli
instead (e.g.,
npx @salesforce/b2c-cli slas client list
).
使用
b2c
CLI插件管理SLAS(Shopper Login and API Access Service,购物者登录与API访问服务)的API客户端和凭据。
重要提示:SLAS用于店面和无头电商的购物者(客户)认证。若要获取管理端令牌(OCAPI、管理端API),请使用
b2c auth token
——详见b2c-config 技能
提示:如果未全局安装
b2c
,可改用
npx @salesforce/b2c-cli
(例如:
npx @salesforce/b2c-cli slas client list
)。

When to Use

使用场景

Common scenarios requiring SLAS client management:
  • Testing Custom APIs: Create a client with custom scopes (e.g.,
    c_loyalty
    ) to test your Custom API endpoints
  • PWA/Headless Development: Configure clients for composable storefronts
  • Integration Testing: Create dedicated test clients with specific scope sets
需要管理SLAS客户端的常见场景:
  • 测试自定义API:创建带有自定义权限范围(如
    c_loyalty
    )的客户端,以测试你的自定义API端点
  • PWA/无头电商开发:为可组合店面配置客户端
  • 集成测试:创建具有特定权限范围集合的专用测试客户端

Examples

示例

List SLAS Clients

列出SLAS客户端

bash
undefined
bash
undefined

list all SLAS clients for a tenant

列出某个租户的所有SLAS客户端

b2c slas client list --tenant-id abcd_123
b2c slas client list --tenant-id abcd_123

list with JSON output

以JSON格式输出结果

b2c slas client list --tenant-id abcd_123 --json
undefined
b2c slas client list --tenant-id abcd_123 --json
undefined

Get SLAS Client Details

获取SLAS客户端详情

bash
undefined
bash
undefined

get details for a specific SLAS client

获取指定SLAS客户端的详情

b2c slas client get --tenant-id abcd_123 --client-id my-client-id
undefined
b2c slas client get --tenant-id abcd_123 --client-id my-client-id
undefined

Create SLAS Client

创建SLAS客户端

bash
undefined
bash
undefined

create a new SLAS client with default scopes (auto-generates UUID client ID)

使用默认权限范围创建新的SLAS客户端(自动生成UUID格式的客户端ID)

b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback
b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback

create with a specific client ID and custom scopes

使用指定客户端ID和自定义权限范围创建客户端

b2c slas client create my-client-id --tenant-id abcd_123 --channels RefArch --scopes sfcc.shopper-products,sfcc.shopper-search --redirect-uri http://localhost:3000/callback
b2c slas client create my-client-id --tenant-id abcd_123 --channels RefArch --scopes sfcc.shopper-products,sfcc.shopper-search --redirect-uri http://localhost:3000/callback

create a public client

创建公开客户端

b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --public
b2c slas client create --tenant-id abcd_123 --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 --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --no-create-tenant
b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --no-create-tenant

output as JSON (useful for capturing the generated secret)

以JSON格式输出结果(便于保存自动生成的密钥)

b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --json

Note: By default, the tenant is automatically created if it doesn't exist.

**Warning:** Use `--scopes` (plural) for client scopes, NOT `--auth-scope` (singular). The `--auth-scope` flag is a global authentication option for OAuth scopes.
b2c slas client create --tenant-id abcd_123 --channels RefArch --default-scopes --redirect-uri http://localhost:3000/callback --json

注意:默认情况下,如果租户不存在,系统会自动创建该租户。

**警告**:请使用`--scopes`(复数形式)设置客户端权限范围,不要使用`--auth-scope`(单数形式)。`--auth-scope`是用于OAuth权限范围的全局认证选项。

Create Client for Custom API Testing

为自定义API测试创建客户端

When testing a Custom API that requires custom scopes:
bash
undefined
当测试需要自定义权限范围的自定义API时:
bash
undefined

Create a private client with custom scope for testing

创建带有自定义权限范围的私有客户端用于测试

Replace c_my_scope with your API's custom scope from schema.yaml

将c_my_scope替换为你的API在schema.yaml中定义的自定义权限范围

b2c slas client create
--tenant-id zzpq_013
--channels RefArch
--default-scopes
--scopes "c_my_scope"
--redirect-uri http://localhost:3000/callback
--json
b2c slas client create
--tenant-id zzpq_013
--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

输出内容包含client_id和client_secret——请保存这些信息用于令牌请求


**Important:** The custom scope in your SLAS client must match the scope defined in your Custom API's `schema.yaml` security section.

**重要提示**:SLAS客户端中的自定义权限范围必须与你的自定义API的`schema.yaml`安全部分中定义的权限范围一致。

Get a Token for Testing

获取测试用令牌

After creating a SLAS client, obtain a token for API testing:
bash
undefined
创建SLAS客户端后,获取用于API测试的令牌:
bash
undefined

Set credentials from client creation output

从客户端创建结果中设置凭据

Find your shortcode in Business Manager: Administration > Site Development > Salesforce Commerce API Settings

在Business Manager中查找你的短代码:Administration > Site Development > Salesforce Commerce API Settings

SHORTCODE="kv7kzm78" # Example shortcode - yours will be different ORG="f_ecom_zzpq_013" CLIENT_ID="your-client-id" CLIENT_SECRET="your-client-secret" SITE="RefArch"
SHORTCODE="kv7kzm78" # 示例短代码——你的短代码会有所不同 ORG="f_ecom_zzpq_013" CLIENT_ID="your-client-id" CLIENT_SECRET="your-client-secret" SITE="RefArch"

Get access token

获取访问令牌

curl -s "https://$SHORTCODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/token"
-u "$CLIENT_ID:$CLIENT_SECRET"
-d "grant_type=client_credentials&channel_id=$SITE"
undefined
curl -s "https://$SHORTCODE.api.commercecloud.salesforce.com/shopper/auth/v1/organizations/$ORG/oauth2/token"
-u "$CLIENT_ID:$CLIENT_SECRET"
-d "grant_type=client_credentials&channel_id=$SITE"
undefined

Update SLAS Client

更新SLAS客户端

bash
undefined
bash
undefined

update an existing SLAS client

更新现有SLAS客户端

b2c slas client update --tenant-id abcd_123 --client-id my-client-id
undefined
b2c slas client update --tenant-id abcd_123 --client-id my-client-id
undefined

Delete SLAS Client

删除SLAS客户端

bash
undefined
bash
undefined

delete a SLAS client

删除SLAS客户端

b2c slas client delete --tenant-id abcd_123 --client-id my-client-id
undefined
b2c slas client delete --tenant-id abcd_123 --client-id my-client-id
undefined

Configuration

配置

The tenant ID can be set via environment variable:
  • SFCC_TENANT_ID
    : SLAS tenant ID (organization ID)
租户ID可通过环境变量设置:
  • SFCC_TENANT_ID
    :SLAS租户ID(组织ID)

More Commands

更多命令

See
b2c slas --help
for a full list of available commands and options in the
slas
topic.
查看
b2c slas --help
获取
slas
主题下的所有可用命令和选项。

Related Skills

相关技能

  • b2c:b2c-custom-api-development
    - Creating Custom APIs that require SLAS authentication
  • b2c-cli:b2c-scapi-custom
    - Checking Custom API registration status
  • b2c:b2c-custom-api-development
    - 创建需要SLAS认证的自定义API
  • b2c-cli:b2c-scapi-custom
    - 检查自定义API的注册状态