跳到主要内容

认证管理

管理认证、凭证和店铺连接。选定的每个店铺都有自己的 Profile。

login​

通过浏览器 OAuth 流程登录 Shoplazza 账户。不带 --store-domain 时只登录账户;用 --store-domain 选定店铺时还需要 --domain 或 --scope(使用 --uat 时除外)。

shell
shoplazza auth login [参数]

CLI 会打印一个授权 URL,在浏览器中打开即可授权。在交互式终端中,CLI 会询问你未传入的店铺和业务域;已登录时直接运行不带参数的 auth login,会先确认是否重新认证。

参数​

参数类型说明
--store-domain, -s <域名>string登录时选定的店铺域名(如 my-store.myshoplaza.com)
--domain <域>StringSlice逗号分隔的业务域,用于作用域扩展(如 products,orders)。可选值:app、billing、checkout、customers、discounts、orders、products、shop、themes、webhook、all
--scope <作用域>StringSlice逗号分隔的 OAuth 作用域(如 read_product,write_product)
--merge-scopesbool同时重新申请此前已授权的全部作用域。登录会替换账户已授权的作用域,不加此参数时,范围更窄的重新登录会丢掉其余作用域
--uat <令牌>string使用已有的账户 UAT 非交互式登录(CI/CD),跳过浏览器
--timeout <秒>intWeb 流程轮询超时时间,单位秒(默认:300)
--poll-interval <秒>intWeb 流程轮询间隔,单位秒(默认:2)

示例​

shell
# 仅登录账户(不选店铺、不申请作用域)
shoplazza auth login

# 指定业务域作用域登录
shoplazza auth login --store-domain my-store.myshoplaza.com --domain products,orders,customers

# 追加某个业务域的作用域,并保留已授权的作用域
shoplazza auth login --store-domain my-store.myshoplaza.com --domain discounts --merge-scopes

# CI/CD 非交互式登录
shoplazza auth login --uat $SHOPLAZZA_UAT --store-domain my-store.myshoplaza.com

logout​

登出并清除所有 Profile 和存储的凭证。在交互式终端中会先请你确认。

shell
shoplazza auth logout

status​

显示当前认证状态:是否已登录、账户、已授权的作用域,以及每个已配置的 Profile 及其店铺和令牌状态。

shell
shoplazza auth status

scopes​

显示支持的 OAuth 作用域,以及账户当前已授权的作用域。

shell
shoplazza auth scopes

store use​

为 --store-domain 申请店铺令牌,创建或复用该店铺的 Profile 并设为当前 Profile,无需重新认证。

shell
shoplazza auth store use [参数]
参数类型说明
--store-domain, -s <域名>string要切换到的店铺域名(必填)
--scope <作用域>StringSlice该店铺 Profile 的作用域(须为账户已授权作用域的子集);留空则保留或授予全部作用域

示例​

shell
shoplazza auth store use --store-domain another-store.myshoplaza.com

# 切换并收窄该 Profile 的作用域
shoplazza auth store use --store-domain another-store.myshoplaza.com --scope read_product,read_order