asc-auth

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

asc auth — Multi-Account Authentication

asc auth — 多账户认证

Manages App Store Connect API key credentials in
~/.asc/credentials.json
. Supports multiple named accounts with an active account that all
asc
commands use automatically.
管理
~/.asc/credentials.json
中的App Store Connect API密钥凭据。支持多个命名账户,且所有
asc
命令会自动使用一个活跃账户。

Commands

命令

login — save an account

login — 保存账户

bash
asc auth login \
  --key-id <KEY_ID> \
  --issuer-id <ISSUER_ID> \
  --private-key-path ~/.asc/AuthKey_KEYID.p8 \
  [--name <alias>]          # optional; defaults to "default"
  [--vendor-number <number>] # optional; for sales/finance reports
  • --name
    must not contain spaces (use hyphens or underscores, e.g.
    work-org
    )
  • If no
    --name
    is given, saves under
    "default"
  • The saved account is automatically set as active
  • Saving to an existing name updates it (safe overwrite)
  • Use
    --private-key
    instead of
    --private-key-path
    to pass raw PEM content
  • --vendor-number
    is optional; saved with credentials for auto-resolution by report commands
Output
AuthStatus
JSON:
json
{
  "data": [{
    "affordances": {
      "check": "asc auth check",
      "list":  "asc auth list",
      "login": "asc auth login --key-id <id> --issuer-id <id> --private-key-path <path>",
      "logout": "asc auth logout"
    },
    "issuerID": "abc-def-456",
    "keyID":    "KEYID123",
    "name":     "work",
    "source":   "file"
  }]
}
bash
asc auth login \
  --key-id <KEY_ID> \
  --issuer-id <ISSUER_ID> \
  --private-key-path ~/.asc/AuthKey_KEYID.p8 \
  [--name <alias>]          # 可选;默认值为"default"
  [--vendor-number <number>] # 可选;用于销售/财务报告
  • --name
    不得包含空格(使用连字符或下划线,例如
    work-org
  • 如果未指定
    --name
    ,则保存到
    "default"
    账户
  • 保存的账户会自动设为活跃账户
  • 保存到现有名称会更新该账户(安全覆盖)
  • 使用
    --private-key
    替代
    --private-key-path
    以传递原始PEM内容
  • --vendor-number
    为可选参数;会与凭据一起保存,供报告命令自动解析
输出
AuthStatus
JSON:
json
{
  "data": [{
    "affordances": {
      "check": "asc auth check",
      "list":  "asc auth list",
      "login": "asc auth login --key-id <id> --issuer-id <id> --private-key-path <path>",
      "logout": "asc auth logout"
    },
    "issuerID": "abc-def-456",
    "keyID":    "KEYID123",
    "name":     "work",
    "source":   "file"
  }]
}

list — show all saved accounts

list — 显示所有已保存账户

bash
asc auth list [--pretty] [--output table]
  • Active account:
    "isActive": true
  • Inactive accounts have a
    "use"
    affordance to switch
Output — array of
ConnectAccount
:
json
{
  "data": [
    {
      "affordances": { "logout": "asc auth logout --name personal", "use": "asc auth use personal" },
      "isActive": false, "issuerID": "...", "keyID": "KEYID1", "name": "personal"
    },
    {
      "affordances": { "logout": "asc auth logout --name work" },
      "isActive": true,  "issuerID": "...", "keyID": "KEYID2", "name": "work"
    }
  ]
}
bash
asc auth list [--pretty] [--output table]
  • 活跃账户:
    "isActive": true
  • 非活跃账户会有一个
    "use"
    操作选项用于切换
输出
ConnectAccount
数组:
json
{
  "data": [
    {
      "affordances": { "logout": "asc auth logout --name personal", "use": "asc auth use personal" },
      "isActive": false, "issuerID": "...", "keyID": "KEYID1", "name": "personal"
    },
    {
      "affordances": { "logout": "asc auth logout --name work" },
      "isActive": true,  "issuerID": "...", "keyID": "KEYID2", "name": "work"
    }
  ]
}

use — switch active account

use — 切换活跃账户

bash
asc auth use <name>
bash
asc auth use <name>

→ Switched to account "work"

→ 已切换到账户"work"


Throws `accountNotFound` if `<name>` doesn't exist. Run `asc auth list` first to see valid names.

如果`<name>`不存在,会抛出`accountNotFound`错误。请先运行`asc auth list`查看有效账户名称。

logout — remove an account

logout — 移除账户

bash
asc auth logout              # removes the active account
asc auth logout --name work  # removes a specific account
bash
asc auth logout              # 移除活跃账户
asc auth logout --name work  # 移除指定账户

→ Logged out successfully

→ 登出成功

undefined
undefined

update — modify an existing account

update — 修改现有账户

bash
asc auth update [--name <alias>] --vendor-number <number>
  • Updates the named account (or active account if
    --name
    is omitted)
  • Currently supports
    --vendor-number
    — the vendor number used by
    sales-reports
    and
    finance-reports
    commands
  • Loads existing credentials, merges the update, and saves back
  • Throws
    accountNotFound
    if the account doesn't exist
Output
AuthStatus
JSON (includes
vendorNumber
):
json
{
  "data": [{
    "affordances": { "check": "asc auth check", "list": "asc auth list", ... },
    "issuerID": "abc-def-456",
    "keyID":    "KEYID123",
    "name":     "work",
    "source":   "file",
    "vendorNumber": "88012345"
  }]
}
bash
asc auth update [--name <alias>] --vendor-number <number>
  • 更新指定账户(如果省略
    --name
    则更新活跃账户)
  • 当前支持
    --vendor-number
    参数 — 供
    sales-reports
    finance-reports
    命令使用的供应商编号
  • 加载现有凭据,合并更新内容后重新保存
  • 如果账户不存在,会抛出
    accountNotFound
    错误
输出 — 包含
vendorNumber
AuthStatus
JSON:
json
{
  "data": [{
    "affordances": { "check": "asc auth check", "list": "asc auth list", ... },
    "issuerID": "abc-def-456",
    "keyID":    "KEYID123",
    "name":     "work",
    "source":   "file",
    "vendorNumber": "88012345"
  }]
}

check — verify active credentials

check — 验证活跃凭据

bash
asc auth check [--pretty] [--output table]
Shows active account name + source (
"file"
or
"environment"
). Shows
vendorNumber
if saved. No
name
field for environment credentials.
bash
asc auth check [--pretty] [--output table]
显示活跃账户名称及来源(
"file"
"environment"
)。如果已保存,会显示
vendorNumber
。环境凭据无
name
字段。

Credential Resolution Order

凭据解析顺序

All
asc
commands resolve credentials in this order:
  1. Active account in
    ~/.asc/credentials.json
    (set by
    auth login
    /
    auth use
    )
  2. Environment variables:
    ASC_KEY_ID
    ,
    ASC_ISSUER_ID
    ,
    ASC_PRIVATE_KEY_PATH
    /
    ASC_PRIVATE_KEY_B64
    /
    ASC_PRIVATE_KEY
所有
asc
命令按以下顺序解析凭据:
  1. ~/.asc/credentials.json
    中的活跃账户
    (通过
    auth login
    /
    auth use
    设置)
  2. 环境变量
    ASC_KEY_ID
    ASC_ISSUER_ID
    ASC_PRIVATE_KEY_PATH
    /
    ASC_PRIVATE_KEY_B64
    /
    ASC_PRIVATE_KEY

Credentials File Format

凭据文件格式

json
{
  "accounts": {
    "personal": { "issuerID": "...", "keyID": "KEYID1", "privateKeyPEM": "..." },
    "work":     { "issuerID": "...", "keyID": "KEYID2", "privateKeyPEM": "...", "vendorNumber": "88012345" }
  },
  "active": "work"
}
The
vendorNumber
field is optional — omitted from JSON when nil. It is used by
sales-reports
and
finance-reports
commands for auto-resolution when
--vendor-number
is not provided.
Legacy migration: Old single-credential files (
{ "keyID": ..., "issuerID": ..., "privateKeyPEM": ... }
) are automatically migrated to a
"default"
named account on first use.
json
{
  "accounts": {
    "personal": { "issuerID": "...", "keyID": "KEYID1", "privateKeyPEM": "..." },
    "work":     { "issuerID": "...", "keyID": "KEYID2", "privateKeyPEM": "...", "vendorNumber": "88012345" }
  },
  "active": "work"
}
vendorNumber
字段为可选参数 — 为空时不会出现在JSON中。当未提供
--vendor-number
参数时,
sales-reports
finance-reports
命令会使用该字段自动解析。
旧版本迁移:首次使用时,旧版单凭据文件(
{ "keyID": ..., "issuerID": ..., "privateKeyPEM": ... }
)会自动迁移到名为
"default"
的账户。

Typical Workflows

典型工作流

First-time setup (single account)

首次设置(单账户)

bash
asc auth login \
  --key-id KEYID123 \
  --issuer-id abc-def-456 \
  --private-key-path ~/.asc/AuthKey_KEYID123.p8

asc auth check --pretty    # verify source: "file"
asc apps list              # works without env vars
bash
asc auth login \
  --key-id KEYID123 \
  --issuer-id abc-def-456 \
  --private-key-path ~/.asc/AuthKey_KEYID123.p8

asc auth check --pretty    # 验证来源:"file"
asc apps list              # 无需环境变量即可运行

Multiple accounts (personal + work)

多账户(个人+工作)

bash
undefined
bash
undefined

Add accounts

添加账户

asc auth login --key-id K1 --issuer-id I1 --private-key-path ~/.asc/personal.p8 --name personal asc auth login --key-id K2 --issuer-id I2 --private-key-path ~/.asc/work.p8 --name work
asc auth login --key-id K1 --issuer-id I1 --private-key-path ~/.asc/personal.p8 --name personal asc auth login --key-id K2 --issuer-id I2 --private-key-path ~/.asc/work.p8 --name work

List all

列出所有账户

asc auth list --pretty
asc auth list --pretty

Switch

切换账户

asc auth use personal asc apps list # now uses personal account
asc auth use work asc apps list # now uses work account
undefined
asc auth use personal asc apps list # 现在使用个人账户
asc auth use work asc apps list # 现在使用工作账户
undefined

Save vendor number for reports

保存供应商编号用于报告

bash
undefined
bash
undefined

During login

登录时保存

asc auth login --key-id K1 --issuer-id I1 --private-key-path key.p8 --vendor-number 88012345
asc auth login --key-id K1 --issuer-id I1 --private-key-path key.p8 --vendor-number 88012345

Or add to existing account

或添加到现有账户

asc auth update --vendor-number 88012345
asc auth update --vendor-number 88012345

Now reports auto-resolve vendor number

现在报告将自动解析供应商编号

asc sales-reports download --report-type SALES --sub-type SUMMARY --frequency DAILY
undefined
asc sales-reports download --report-type SALES --sub-type SUMMARY --frequency DAILY
undefined

Remove an account

移除账户

bash
asc auth list              # find the name
asc auth logout --name personal
asc auth list              # confirm removal
bash
asc auth list              # 查找账户名称
asc auth logout --name personal
asc auth list              # 确认已移除

Error Reference

错误参考

SituationResolution
accountNotFound("ghost")
Run
asc auth list
to see valid names
Name contains spacesUse hyphens/underscores:
--name my-org
401 Unauthorized on API callsRun
asc auth check
to verify active credentials
No credentials anywhereRun
asc auth login
or set
ASC_KEY_ID
env var
场景解决方法
accountNotFound("ghost")
运行
asc auth list
查看有效账户名称
账户名称包含空格使用连字符/下划线:
--name my-org
API调用返回401未授权运行
asc auth check
验证活跃凭据
无任何可用凭据运行
asc auth login
或设置
ASC_KEY_ID
环境变量