google-cloud-platform - GCP 云外壳错误 : No credentialed accounts

标签 google-cloud-platform google-cloud-shell

我正在做 GoogleCloudReady Facilitator Program workshop labs,我在做实验时遇到了问题。

当我尝试运行 gcloud auth list 命令时,我面临着


To login, run:
  $ gcloud auth login `ACCOUNT` 

我的预期输出应该是

[core]
project = <project_ID>

以及根据文档。

请帮帮我,我的时间已经过去了。

最佳答案

正如之前一些评论提到的,您需要先进行身份验证。根据您遵循的指南或实验室,可能会为您设置配置或初始化。

例如:在这个qwiklab无需运行 gcloud auth login因为 shell 已在配置文件中为您初始化,因此您可以使用 gcloud auth list无需运行第一个命令。

在实验室之外,在控制台中或使用 CLI,您需要制作一些 Configurations :

A configuration is a set of gcloud CLI properties. A configuration works like a profile.

When you start using the gcloud CLI, you'll work with a single configuration named default and you can set properties by running gcloud init or gcloud config set. This single default configuration is suitable for most use cases.

这是设置gcloud CLI时的第一步,Initializing the gcloud CLI .

gcloud init performs the following setup steps:

  • Authorizes the gcloud CLI to use your user account credentials to access Google Cloud, or lets you select an account if you have previously authorized access

  • Sets up a gcloud CLI configuration and sets a base set of properties, including the active account from the step above, the current project, and if applicable, the default Compute Engine region and zone

You can run the following as alternatives to gcloud init:

<表类="s-表"> <头> 命令 描述 <正文> gcloud auth login 在不设置配置的情况下使用用户帐户授权。 gcloud auth activate-service-account 使用服务帐户而不是用户帐户进行授权。用于非交互授权且无需网络浏览器。 ... ...

因此,根据具体情况,您可能只需要指出您正在使用哪个用户帐户的 shell(以防它没有像前面提到的 qwiklab 中的 image 那样指定,它会为您完成所有初始化)使用 gcloud auth login ,或者您可能需要使用 gcloud init 设置一个全新的配置文件.

在这种情况下,您是 listing accounts无需先进行身份验证,这就是它打印该消息的原因。

执行登录/初始化命令后,您可以get the active authenticated gcloud account或列出您之前尝试过的帐户,以确认您现在使用的是正确的帐户。

关于google-cloud-platform - GCP 云外壳错误 : No credentialed accounts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72232568/

相关文章:

google-cloud-platform - 执行 sql 查询 gcloud 命令行

angular - ERROR : (gcloud. builds.submit) HTTPError 403: 存储桶 "project name"的帐户尚未启用计费

java - 是否可以使用 KafkaIO.read 为单个管道的两个不同集群指定 Kafka 引导服务器?

python-3.x - 如何在Google Cloud Shell中安装Python 3.7

google-cloud-platform - GCP 仅对云 shell 开放防火墙

google-cloud-platform - 如何修复 GCP CommandException : "lifecycle" command spanning providers not allowed 中的错误

amazon-web-services - 在云端特定时间运行docker容器

google-cloud-platform - 有没有办法在 Google Cloud Platform 中安排 Cloud Shell 命令?

google-cloud-sql - Google Cloud SQL 从存储桶导入 : error 403

java - 如何在 Google Cloud Platform 上的 Shell 中运行 Headless Chrome