MongoDB Atlas 身份验证。
此命令允许您使用用户帐户、服务帐户或API密钥身份验证方法对MongoDB Atlas进行身份验证。
注意:如果您在环境变量中设立了凭证,则这些档案优先于您在身份验证期间提供的值。要学习;了解更多信息,请参阅 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、ServiceAccount 或 APIKey。如果设立,则跳过身份验证类型提示。 |
--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 | 保存到配置文件的默认输出格式。有效值为明文或 json。如果设立,则跳过输出格式提示。 |
--privateApiKey | 字符串 | false | 私有API密钥。必须与 --publicApiKey、--authType 和 --output 一起设立。如果均已设立,则跳过凭证提示。 |
--projectId | 字符串 | false | 要另存为配置文件默认的项目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