MongoDB Atlas 身份验证。
此命令允许您使用用户帐户、服务帐户或API密钥身份验证方法对MongoDB Atlas进行身份验证。
用户账户登录使用带有本地回调服务器的授权码和 PKCE 流程。要改用已弃用的设备代码流程,请运行 atlas auth login --authType=UserAccountLegacy --output plaintext。
注意:如果您在环境变量中设置了凭证,它们将优先于您在身份验证期间提供的值。要学习;了解更多信息,请参阅 https://www.mongodb.com/zh-cn/docs/atlas/cli/current/atlas-cli-env-variables/#precedence.
要以非交互方式登录,请设置 --authType、--output 以及该类型所需的凭证标志(ServiceAccount 使用 --clientId 和 --clientSecret,或 APIKeys 使用 --publicApiKey 和 --privateApiKey)。如果使用其中任何一个标志而没有使用完成流程所需的其他标志,则会返回错误,而不是提示。
如果没有 --orgId 或 --projectId,则仅当凭证可以访问一个组织或项目时,才会保存默认值。
语法
命令语法
atlas auth login [options]选项
名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
--authType | 字符串 | false | 要使用的身份验证类型。有效值为 UserAccount、 UserAccountLegacy、 ServiceAccount 或 APIKeys。如果设置,则跳过身份验证类型提示。 |
--clientId | 字符串 | false | 服务账号客户端 ID。必须与 --clientSecret、--authType 和 --output 一起设置。如果全部设置,则跳过凭证提示。 |
--clientSecret | 字符串 | false | 服务账号客户端密钥。必须与 --clientId、--authType 和 --output 一起设置。如果全部设置,则跳过凭证提示。 |
--gov | false | 登录 Atlas for Government。 | |
-h,--help | false | 登录帮助信息 | |
--noBrowser | false | 不要自动打开浏览器会话。 | |
--orgId | 字符串 | false | 要保存为个人资料默认设置的组织ID。如果设置,则跳过组织提示。 |
-o, --output | 字符串 | false | 保存到配置文件的默认输出格式。有效值为 plaintext 或 json。如果设置,则跳过输出格式提示。 |
--privateApiKey | 字符串 | false | 私有API密钥。必须与 --publicApiKey、--authType 和 --output 一起设置。如果全部设置,则跳过凭证提示。 |
--projectId | 字符串 | false | 要保存为配置文件默认值的群组 ID(group ID)。如果设置,则跳过项目提示。 |
--publicApiKey | 字符串 | false | 公用API密钥。必须与 --privateApiKey、--authType 和 --output 一起设置。如果全部设置,则跳过凭证提示。 |
继承选项
名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
-P, --profile | 字符串 | false | 要从您的配置文件中使用的配置文件的名称。要学习;了解Atlas CLI配置文件,请参阅 https://dochub.mongodb.org/core/atlas-cli-save-connection-settings. |
示例
# Log in to your MongoDB Atlas account in interactive mode:atlas auth login# Log in non-interactively with a Service Account:atlas auth login --authType ServiceAccount --clientId <clientId> --clientSecret <clientSecret> --output plaintext# Log in non-interactively with a Service Account and store the default organization and project:atlas auth login --authType ServiceAccount --clientId <clientId> --clientSecret <clientSecret> --output plaintext --orgId <orgId> --projectId <projectId># Log in non-interactively with API Keys:atlas auth login --authType APIKeys --publicApiKey <publicApiKey> --privateApiKey <privateApiKey> --output plaintext