See Details
目录
注意:你必须使用 npm 5.5.1 或更高版本才能使用访问令牌。
¥Note: You must be using npm version 5.5.1 or greater to use access tokens.
在使用 API 或 npm 命令行接口 (CLI) 时,访问令牌是使用你的用户名和密码对 npm 进行身份验证的替代方法。访问令牌是可用于身份验证的十六进制字符串,它赋予你安装和/或发布模块的权利。
¥An access token is an alternative to using your username and password for authenticating to npm when using the API or the npm command-line interface (CLI). An access token is a hexadecimal string that you can use to authenticate, and which gives you the right to install and/or publish your modules.
有两种类型的访问令牌可用:
¥There are two types of access tokens available:
你可以创建访问令牌以授予其他工具(例如持续集成测试环境)访问你的 npm 包的权限。例如,GitHub Actions 提供了存储 密码 的能力,例如访问令牌,你随后可以使用它来进行身份验证。当你的工作流程运行时,它将能够像你一样完成 npm 任务,包括安装你可以访问的私有包。
¥You can create access tokens to give other tools (such as continuous integration testing environments) access to your npm packages. For example, GitHub Actions provides the ability to store secrets, such as access tokens, that you can then use to authenticate. When your workflow runs, it will be able to complete npm tasks as you, including installing private packages you can access.
你可以使用来自 Web 或 CLI 的令牌,以最简单的为准。你在每个环境中所做的事情都会反映在另一个环境中。
¥You can work with tokens from the web or the CLI, whichever is easiest. What you do in each environment will be reflected in the other environment.
npm 令牌命令让你:
¥npm token commands let you:
-
查看令牌以便于跟踪和管理
¥View tokens for easier tracking and management
-
创建新的旧版令牌
¥Create new legacy tokens
-
根据 IP 地址范围 (CIDR) 限制访问
¥Limit access according to IP address ranges (CIDR)
-
删除/撤销令牌
¥Delete/revoke tokens
有关在 Web 和 CLI 上创建和查看访问令牌的更多信息,请参阅“创建和查看访问令牌”。
¥For more information on creating and viewing access tokens on the web and CLI, see "Creating and viewing access tokens".