您的凭据无效。请运行$ gcloud auth login

时间:2017-03-14 03:13:29

标签: authentication google-cloud-storage gcloud gsutil

gsutil在我的系统上独立工作。 然后我安装了SDK,包括一些身份验证的东西。 现在gsutil说我的凭据无效。

$ gcloud auth login wolfvolpi@gmail.com
WARNING: `gcloud auth login` no longer writes application default credentials.
If you need to use ADC, see:
  gcloud auth application-default --help

You are now logged in as [redacted].
Your current project is [redacted].  You can change this setting by running:
  $ gcloud config set project PROJECT_ID
$ gsutil ls
Your credentials are invalid. Please run
  $ gcloud auth login

如何设置我的凭据以便gsutil再次运行?

$ gcloud version
Google Cloud SDK 146.0.0
core 2017.02.28
core-nix 2017.02.28
gcloud 
gcloud-deps 2017.02.28
gcloud-deps-linux-x86_64 2017.02.28
gsutil 4.22
gsutil-nix 4.22

2 个答案:

答案 0 :(得分:2)

如果您以前使用凭据配置了gsutil,则可能是它正在拾取那些在Cloud SDK模式下不再有效的旧凭据。看看你的boto文件(通常是〜/ .boto)并删除那里找到的任何凭据。

您可以在此处查看boto文件中的有效字段列表:https://cloud.google.com/storage/docs/gsutil/commands/config#additional-configuration-controllable-features

答案 1 :(得分:0)

标记的解决方案有时不起作用。但是您可以使用

创建一个新的配置设置

gcloud 初始化

Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [old config file's name] are:
core:
  account: [account]
  disable_usage_reporting: 'True'
  project: [projectname]

Pick configuration to use:
 [1] Re-initialize this configuration [old config file's name] with new settings
 [2] Create a new configuration
 [3] Switch to and re-initialize existing configuration: [default]
Please enter your numeric choice:

然后您可以使用选项 2 创建新配置。试试这对那些无法使用上述解决方案完成的人有用。

当有人无法使用 gsutil cors set [filename].json gs://[BucketName] 命令设置 CORS 时,这也将起作用。

然后再试一次。