b2c-slas
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseB2C SLAS Skill
B2C SLAS 技能
Use the CLI plugin to manage SLAS (Shopper Login and API Access Service) API clients and credentials.
b2cImportant: SLAS is for shopper (customer) authentication used by storefronts and headless commerce. For admin tokens (OCAPI, Admin APIs), use- see b2c-config skill.b2c auth token
Tip: Ifis not installed globally, useb2cinstead (e.g.,npx @salesforce/b2c-cli).npx @salesforce/b2c-cli slas client list
使用 CLI插件管理SLAS(Shopper Login and API Access Service,购物者登录与API访问服务)的API客户端和凭据。
b2c重要提示:SLAS用于店面和无头电商的购物者(客户)认证。若要获取管理端令牌(OCAPI、管理端API),请使用——详见b2c-config 技能。b2c auth token
提示:如果未全局安装,可改用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., ) to test your Custom API endpoints
c_loyalty - PWA/Headless Development: Configure clients for composable storefronts
- Integration Testing: Create dedicated test clients with specific scope sets
需要管理SLAS客户端的常见场景:
- 测试自定义API:创建带有自定义权限范围(如)的客户端,以测试你的自定义API端点
c_loyalty - PWA/无头电商开发:为可组合店面配置客户端
- 集成测试:创建具有特定权限范围集合的专用测试客户端
Examples
示例
List SLAS Clients
列出SLAS客户端
bash
undefinedbash
undefinedlist 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
undefinedb2c slas client list --tenant-id abcd_123 --json
undefinedGet SLAS Client Details
获取SLAS客户端详情
bash
undefinedbash
undefinedget details for a specific SLAS client
获取指定SLAS客户端的详情
b2c slas client get --tenant-id abcd_123 --client-id my-client-id
undefinedb2c slas client get --tenant-id abcd_123 --client-id my-client-id
undefinedCreate SLAS Client
创建SLAS客户端
bash
undefinedbash
undefinedcreate 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
undefinedCreate 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
--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
--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
undefinedSet 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"
-u "$CLIENT_ID:$CLIENT_SECRET"
-d "grant_type=client_credentials&channel_id=$SITE"
undefinedcurl -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"
-u "$CLIENT_ID:$CLIENT_SECRET"
-d "grant_type=client_credentials&channel_id=$SITE"
undefinedUpdate SLAS Client
更新SLAS客户端
bash
undefinedbash
undefinedupdate an existing SLAS client
更新现有SLAS客户端
b2c slas client update --tenant-id abcd_123 --client-id my-client-id
undefinedb2c slas client update --tenant-id abcd_123 --client-id my-client-id
undefinedDelete SLAS Client
删除SLAS客户端
bash
undefinedbash
undefineddelete a SLAS client
删除SLAS客户端
b2c slas client delete --tenant-id abcd_123 --client-id my-client-id
undefinedb2c slas client delete --tenant-id abcd_123 --client-id my-client-id
undefinedConfiguration
配置
The tenant ID can be set via environment variable:
- : SLAS tenant ID (organization ID)
SFCC_TENANT_ID
租户ID可通过环境变量设置:
- :SLAS租户ID(组织ID)
SFCC_TENANT_ID
More Commands
更多命令
See for a full list of available commands and options in the topic.
b2c slas --helpslas查看获取主题下的所有可用命令和选项。
b2c slas --helpslasRelated Skills
相关技能
- - Creating Custom APIs that require SLAS authentication
b2c:b2c-custom-api-development - - Checking Custom API registration status
b2c-cli:b2c-scapi-custom
- - 创建需要SLAS认证的自定义API
b2c:b2c-custom-api-development - - 检查自定义API的注册状态
b2c-cli:b2c-scapi-custom