Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCloud command line is executing from different account error

I have two GCloud accounts, consider x & y. I ran the command gcloud config set account x as only account x has access to that particular gcloud project. But everytime I run a local job task such as: python -m trainer.task --bucket=bucket-name --output_dir=outputdir --job-dir=./tmp --train_steps=200 I get the following error:

tensorflow.python.framework.errors_impl.PermissionDeniedError: Error executing an HTTP request: HTTP response code 403 with body '{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "forbidden",
    "message": "y does not have storage.objects.create access to bucket-name."
   }
  ],
  "code": 403,
  "message": "y does not have storage.objects.create access to bucket-name."
 }
}

It seems to me that the command line is accessing the y account even though I am logged into the x account. I double checked that I am logged into the right account with access to the right project.

like image 354
Jai Kotia Avatar asked Jun 13 '26 02:06

Jai Kotia


2 Answers

I ran into this issue trying to upload some files to GCS through an API.

It seems that APIs use the default account and not the account you are signed in to.

Fix:

gcloud auth application-default login Followed by the auth flow.

That fixed it for me like @joan grau noel mentioned. I had to go through a new auth flow to allow Auth Library access via the browser. After changing the default service account to the one I needed the errors stopped.

like image 178
macc Avatar answered Jun 15 '26 15:06

macc


The gcloud config set command seems to only affect the Cloud SDK authentification-wise. This means that despite having the account x set as default, the API calls are still done through the application-default credentials.

If you want to log in with the account y, using the gcloud auth login y command should do the trick. I understand that this is your local developement environment, so you should have no problems after doing this.

As well, in the Ml-engine is recommended to use the gcloud ml-engine local train command to run the jobs to run the jobs locally (Documentation on this), you can see this example on how to do it.

like image 41
Joan Grau Noël Avatar answered Jun 15 '26 15:06

Joan Grau Noël



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!