2
votes

I'm trying to get Google Cloud Vision to work with node.js by following their documentation here. Although I keep getting:

PERMISSION_DENIED: Cloud Vision API has not been used in project 5678.. before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/vision.googleapis.com/overview?project=5678.. then retry

To note though the project number is very different from what I see in gcloud's output when I gather information from the following commands:

gcloud info |tr -d '[]' | awk '/project:/ {print $2}'

'my-set-project' <=== set project id in use

gcloud projects list

which outputs:

PROJECT_ID='my-set-project' // <=== Same id as "gcloud info" command
NAME='my-project-name'
PROJECT_NUMBER=1234.. // <===== Different number from Node.js Error

I have already enabled the api, downloaded a service key and setup the export GOOGLE_APPLICATION_CREDENTIALS=[path/to/my/service/key]. But right now I believe that the service key linkup is not the issue yet as I have not yet really have had gcloud pointing to 'my-set-project'.

I have also found a default.config at

cat /Users/My_Username/.config/gcloud/application_default_credentials.json

which has:

{ "client_id": "5678..-fgrh // <=== same number id as node.js error

So how can I get gcloud-cli to switch to project "1234" which has the API enabled there? I thought doing the command:

gcloud config set project 'my-set-project'

would get running node apps using gcp to use the project of '1234' instead of the default '5678'. Any help will be appreciated as I'm still getting used to the gcloud-cli. Thanks

1

1 Answers

0
votes

Try: gcloud auth activate-service-account --key-file=/path/to/your/service_account.json