Zac*_*man 25
你有几个选择(取决于你究竟想做什么).
第一个选项是使用该--no-launch-browser选项登录.这仍然需要来自人类用户的交互,但不需要您正在使用的计算机上的浏览器:
> gcloud auth login --no-launch-browser
Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute&access_type=offline
Enter verification code: *********************************************
Saved Application Default Credentials.
You are now logged in as [user@example.com].
Your current project is [None]. You can change this setting by running:
$ gcloud config set project PROJECT_ID
Run Code Online (Sandbox Code Playgroud)
非交互选项涉及服务帐户.链接的文档比我更好地解释了它们,但您需要做的简短版本如下:
在Google Developers Console中创建服务帐户.确保它具有适当的"范围"(这些是确定此服务帐户可以执行的操作的权限.下载相应的JSON密钥文件.
跑gcloud auth activate-service-account --key-file <path to key file>.
请注意,Google Compute Engine虚拟机的服务帐户略有不同; 差异在这里描述.
| 归档时间: |
|
| 查看次数: |
13157 次 |
| 最近记录: |