# @contentstack/cli-auth 中文文档

规范地址：https://npmcn.com/package/%40contentstack/cli-auth/

版本：2\.0\.2
npm 元数据更新时间：2026-10-06T09:14:41.978Z
中文译文更新时间：2026-11-10T16:47:38.573Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40contentstack/cli-auth
原文对照：https://npmcn.com/package/%40contentstack/cli-auth/?lang=original
项目主页：https://github.com/contentstack/cli
源码仓库：https://github.com/contentstack/cli

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：88.6 kB，33 个文件
- TypeScript 类型：未声明
- Node.js 要求：\>=22\.0\.0
- 运行依赖：5 个
- 首次发布：2020-10-15T07:31:34.963Z
- 最新版本发布：2026-10-06T09:14:41.817Z
- 近 30 天下载量：44059（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：83（近 12 个月 37 个）

## 中文简介

用于认证活动的内存 CLI 插件

## 安装

```sh
npm install @contentstack/cli-auth
```

也可以使用：`pnpm add @contentstack/cli-auth`、`yarn add @contentstack/cli-auth`、`bun add @contentstack/cli-auth`

## README

# @contentstack/cli-auth (英语)

Contack 的 CLI 插件来进行认证相关活动 。 要从认证开始,请参考 [CLI 认证文件](https://www.contentstack.com/docs/headless-cms/cli/authentication)

[![License](https://img.shields.io/npm/l/@contentstack/cli)](https://github.com/contentstack/cli/blob/main/LICENSE)

-   [@contentstack/cli-auth (英语)](https://npmcn.com/package/%40contentstack/cli-auth/#readme-contentstackcli-auth)
-   [使用量](https://npmcn.com/package/%40contentstack/cli-auth/#readme-usage)
-   [图标](https://npmcn.com/package/%40contentstack/cli-auth/#readme-commands)

# 使用量

```sh-session
$ npm install -g @contentstack/cli-auth
$ csdx COMMAND
running command...
$ csdx (--version)
@contentstack/cli-auth/2.0.2 linux-x64 node-v22.23.3
$ csdx --help [COMMAND]
USAGE
  $ csdx COMMAND
...
```

# 图标

-   [`csdx auth:login`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authlogin)
-   [`csdx auth:logout`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authlogout)
-   [`csdx auth:tokens`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authtokens)
-   [`csdx auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authtokensadd--a-value---delivery---management--e-value--k-value--y---token-value)
-   [`csdx auth:tokens:list`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authtokenslist)
-   [`csdx auth:tokens:remove`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authtokensremove)
-   [`csdx auth:whoami`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-authwhoami)
-   [`csdx login`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-login)
-   [`csdx logout`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-logout)
-   [`csdx whoami`](https://npmcn.com/package/%40contentstack/cli-auth/#readme-csdx-whoami)

## `csdx auth:login`

用户会话登录

```
USAGE
  $ csdx auth:login [-u <value> | --oauth] [-p <value> | ]

FLAGS
  -p, --password=<value>  Password of your Contentstack app.
  -u, --username=<value>  Email address of your Contentstack account.
      --oauth             Enables single sign-on (SSO) in Contentstack CLI.

DESCRIPTION
  User sessions login

ALIASES
  $ csdx login

EXAMPLES
  $ csdx auth:login

  $ csdx auth:login -u <username>

  $ csdx auth:login -u <username> -p <password>

  $ csdx auth:login --username <username>

  $ csdx auth:login --username <username> --password <password>
```

_参见代码 : [src/commands/auth/login.ts (中文(简体) )](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/login.ts)_

## `csdx auth:logout`

用户会话登录

```
USAGE
  $ csdx auth:logout [-y]

FLAGS
  -y, --yes  Force log out by skipping the confirmation.

DESCRIPTION
  User session logout

ALIASES
  $ csdx logout

EXAMPLES
  $ csdx auth:logout

  $ csdx auth:logout -y

  $ csdx auth:logout --yes
```

_参见代码 : [src/commands/auth/logout.ts (中文(简体) )](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/logout.ts)_

## `csdx auth:tokens`

管理 API 访问的认证符

```
USAGE
  $ csdx auth:tokens [--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate]
    [--no-header] [--output csv|json|yaml]

TABLE FLAGS
  --columns=<value>  Specify columns to display, comma-separated.
  --csv              Output results in CSV format.
  --filter=<value>   Filter rows by a column value (e.g., name=foo).
  --no-header        Hide table headers in output.
  --no-truncate      Prevent truncation of long text in columns.
  --output=<option>  Specify output format: csv, json, or yaml.
                     <options: csv|json|yaml>
  --sort=<value>     Sort the table by a column. Use "-" for descending.

DESCRIPTION
  Manage authentication tokens for API access

EXAMPLES
  $ csdx auth:tokens:list

  $ csdx auth:tokens:add --alias mytoken

  $ csdx auth:tokens:remove --alias mytoken
```

_参见代码 : [src/commands/auth/tokens/index.ts 互联网档案馆的存檔,存档日期2013-12-02](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/index.ts)_

## `csdx auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]`

添加管理/ 交付令牌到您的会话中, 以便与其他 CLI 命令使用

```
USAGE
  $ csdx auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]

FLAGS
  -a, --alias=<value>          Alias (name) you want to assign to the token
  -e, --environment=<value>    Environment name for delivery token
  -k, --stack-api-key=<value>  Stack API Key
  -y, --yes                    Use this flag to skip confirmation
      --delivery               Set this flag to save delivery token
      --management             Set this flag to save management token
      --token=<value>          [env: TOKEN] Add the token name

DESCRIPTION
  Adds management/delivery tokens to your session to use it with other CLI commands

EXAMPLES
  $ csdx auth:tokens:add

  $ csdx auth:tokens:add -a <alias>

  $ csdx auth:tokens:add -k <stack api key>

  $ csdx auth:tokens:add --delivery

  $ csdx auth:tokens:add --management

  $ csdx auth:tokens:add -e <environment>

  $ csdx auth:tokens:add --token <token>

  $ csdx auth:tokens:add -a <alias> -k <stack api key> --management --token <management token>

  $ csdx auth:tokens:add -a <alias> -k <stack api key> --delivery -e <environment> --token <delivery token>

  $ csdx auth:tokens:add --alias <alias> --stack-api-key <stack api key> --management --token <management token>

  $ csdx auth:tokens:add --alias <alias> --stack-api-key <stack api key> --delivery -e <environment> --token <delivery token>
```

_参见代码 : [src/commands/auth/tokens/add.ts 互联网档案馆的存檔,存档日期2013-12-21](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/add.ts)_

## `csdx auth:tokens:list`

列出添加到会话中的所有现有符号

```
USAGE
  $ csdx auth:tokens:list [--columns <value>] [--sort <value>] [--filter <value>] [--csv] [--no-truncate]
    [--no-header] [--output csv|json|yaml]

TABLE FLAGS
  --columns=<value>  Specify columns to display, comma-separated.
  --csv              Output results in CSV format.
  --filter=<value>   Filter rows by a column value (e.g., name=foo).
  --no-header        Hide table headers in output.
  --no-truncate      Prevent truncation of long text in columns.
  --output=<option>  Specify output format: csv, json, or yaml.
                     <options: csv|json|yaml>
  --sort=<value>     Sort the table by a column. Use "-" for descending.

DESCRIPTION
  Lists all existing tokens added to the session

EXAMPLES
  $ csdx auth:tokens:list
```

_参见代码 : [src/commands/auth/tokens/list.ts (简体中文)](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/list.ts)_

## `csdx auth:tokens:remove`

删除选中的令牌

```
USAGE
  $ csdx auth:tokens:remove [-a <value>]

FLAGS
  -a, --alias=<value>  Alias (name) of the token to delete.

DESCRIPTION
  Removes selected tokens

EXAMPLES
  $ csdx auth:tokens:remove

  $ csdx auth:tokens:remove -a <alias>
```

_参见代码 : [src/commands/auth/tokens/remove.ts 互联网档案馆的存檔,存档日期2013-12-02](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/tokens/remove.ts)_

## `csdx auth:whoami`

显示当前用户的电子邮件地址

```
USAGE
  $ csdx auth:whoami

DESCRIPTION
  Display current user's email address

ALIASES
  $ csdx whoami

EXAMPLES
  $ csdx auth:whoami
```

_参见代码 : [src/命令/自动/whoami.ts](https://github.com/contentstack/cli/blob/main/packages/contentstack-auth/src/commands/auth/whoami.ts)_

## `csdx login`

用户会话登录

```
USAGE
  $ csdx login [-u <value> | --oauth] [-p <value> | ]

FLAGS
  -p, --password=<value>  Password of your Contentstack app.
  -u, --username=<value>  Email address of your Contentstack account.
      --oauth             Enables single sign-on (SSO) in Contentstack CLI.

DESCRIPTION
  User sessions login

ALIASES
  $ csdx login

EXAMPLES
  $ csdx auth:login

  $ csdx auth:login -u <username>

  $ csdx auth:login -u <username> -p <password>

  $ csdx auth:login --username <username>

  $ csdx auth:login --username <username> --password <password>
```

## `csdx logout`

用户会话登录

```
USAGE
  $ csdx logout [-y]

FLAGS
  -y, --yes  Force log out by skipping the confirmation.

DESCRIPTION
  User session logout

ALIASES
  $ csdx logout

EXAMPLES
  $ csdx auth:logout

  $ csdx auth:logout -y

  $ csdx auth:logout --yes
```

## `csdx whoami`

显示当前用户的电子邮件地址

```
USAGE
  $ csdx whoami

DESCRIPTION
  Display current user's email address

ALIASES
  $ csdx whoami

EXAMPLES
  $ csdx auth:whoami
```

## 常见问题

### @contentstack/cli-auth 是什么？

用于认证活动的内存 CLI 插件

### 如何安装 @contentstack/cli-auth？

在项目目录运行 npm install @contentstack/cli-auth，或使用 pnpm add / yarn add / bun add。

### @contentstack/cli-auth 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/contentstack\_\_cli-auth 是否存在。

### @contentstack/cli-auth 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @contentstack/cli-auth 可以商用吗？

@contentstack/cli-auth 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @contentstack/cli-auth 的下载量有多少？

根据 npm 官方下载统计，@contentstack/cli-auth 在 2026/10/11 – 2026/11/09 这 30 天内被下载 44,059 次，日均约 1,469 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @contentstack/cli-auth 还在维护吗？

最新版本 2\.0\.2 发布于 2026/10/06（1 个月前）；至今共发布 83 个版本，其中过去 12 个月发布了 37 个；首次发布于 2020/10/15。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

