1

gsutil was working as a stand-alone on my system. Then I installed SDK, including some authentication stuff. Now gsutil says my credentials are invalid.

$ 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

How to set my credentials so that gsutil runs again?

$ 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
wolfv
  • 971
  • 12
  • 20

2 Answers2

4

If you previously had gsutil configured with credentials, it is possible that it is picking up those old credentials that will no longer work in the Cloud SDK mode. Take a look in your boto file (typically at ~/.boto) and remove any credentials found in there.

You can see the list of the valid fields in the boto file here: https://cloud.google.com/storage/docs/gsutil/commands/config#additional-configuration-controllable-features

Mark
  • 2,265
  • 15
  • 13
  • 1
    Well that was a simple fix. Thank you so much for sharing your expertise! – wolfv Mar 15 '17 at 01:26
  • Adding on to this, for ubuntu it is localed in ~/.gsutils/credstore2. if you just `mv` both the lock file and the store to another directory it will clear the cache and once you run `gsutil ls` again, it'll grab the new creds and see the new credstore there – John Huynh Sep 23 '20 at 17:31
0

The marked solution did not work sometimes. But You can create a new configure setting by using the

gcloud init

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:

Then you can use option 2 to create new configuration. Try this will work these who not able to done using the above solution.

Also this will work when someone cannot use gsutil cors set [filename].json gs://[BucketName] command to set CORS.

Then try again.

nipun-kavishka
  • 842
  • 12
  • 21