google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission

20.3k Views Asked by At

I have used AutoMl Vision api from gcp and trained it with my custom dataset. I'm able to get predict the data GCP console but not able to store the predicted output. For the purpose of storing the predicted data output and to use my local data for prediction I tried the python code that was given as part of API which accepts the image file content, project name and bucket name but when I try to run it is showing me the error: google.api_core.exceptions.PermissionDenied: 403 The caller does not have permission cloud sdk error output

2

There are 2 best solutions below

3
On

it is simple first the google cloud documentation is not in sync with the code: Please follow these steps:

1) Open command prompt and fire this: set GOOGLE_APPLICATION_CREDENTIALS= /path/to/your/credentials.json (its best to put it in the same folder as google cloud sdk

2) gcloud auth login ( a webpage will be opened saying you are authenticated after you login in to your google account)

3) gcloud config set project YOUR PROJECT_ID

4) gcloud auth activate-service-account YOUR SERVICE [email protected]

5) gcloud projects add-iam-policy-binding YOUR PROJECT_ID --member serviceAccount: (the service account you used in step 4)

6)gcloud projects add-iam-policy-binding YOUR PROJECT_ID --member user: (the email you have affiliated to your gcloud account)

7) Done.

if you do have any issues creating a service account see this video: create and use service account

Hope it helps :)

sources: i had the same problem

0
On

I was facing the same issue until I added "Cloud Datastore persmission" to my service account in order to access firestore data.