问题
I created a GCP project to play around with the video-intelligence API. I enabled the API on my project and launched a Cloud Shell.
I then copied the code from github and followed the README instructions.
However, when I try to run faces.py
I get this error message:
StatusCode.PERMISSION_DENIED, Google Cloud Video Intelligence API has not been used in project cloud-devshell-dev before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/videointelligence.googleapis.com/overview?project=cloud-devshell-dev then retry
Why is it pointing to project=cloud-devshell-dev
and not to my videointel
project?
If I gcloud config list
I can see the correct project and service account. Baffled.
回答1:
Create a service account and have your application use it for API access, run:
$ gcloud iam service-accounts create my-account
$ gcloud iam service-accounts keys create key.json
--iam-account=my-account@my-project.iam.gserviceaccount.com
$ export GOOGLE_APPLICATION_CREDENTIALS=key.json
In the second command replace my-project
with your Project ID.
来源:https://stackoverflow.com/questions/44184869/google-cloud-shell-is-using-project-cloud-devshell-dev-instead-of-my-actual-proj