Google Cloud Vision API "PERMISSION_DENIED"

I am trying to use the Google Cloud Vision API (beta) and it returns the message "Permission Denied". But the project includes a "cloud vision API." Any help is appreciated.

Error Details from Google API Explorer

403 OK

- Show headers -

{
 "error": {
  "code": 403,
  "message": "Project has not activated the vision.googleapis.com API. Please enable the API for project google.com:apisexplorerconsole (#292824132082).",
  "status": "PERMISSION_DENIED",
  "details": [
   {
    "@type": "type.googleapis.com/google.rpc.Help",
    "links": [
     {
      "description": "Google developers console API activation",
      "url": "https://console.developers.google.com/project/292824132082/apiui/api"
     }
    ]
   }
  ]
 }
}
+4
source share
5 answers

You should start by using a CURL request instead of an API browser or instead of your favorite programming language:

curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=put_your_browser_secret_key_here--data-binary @ put_your_req.json > result.json

{
"requests":[
{
  "image":{
    "content":"put_your_encoded_base64_image_content"
  },
  "features":[
    {
      "type":"LABEL_DETECTION",
      "maxResults":4
    }
  ]
}
]
}

:

base64 your_image > your_encoded_base64_image_content

, , , API- .

+3
+1

GOOGLE_APPLICATION_CREDENTIALS - , . , , . gcloud

0

google vision api:

GCV_API_KEY="YOUR_GOOGLE_VISION_API_KEY"

base64:

BASE64_IMAGE=$( base64 image.jpg )

json google:

echo "{\"requests\":[{\"image\":{\"content\":\"$BASE64_IMAGE\"},\"features\":[{\"type\":\"LABEL_DETECTION\",\"maxResults\":4}]}]}" > gcv_label_request.json

json google:

echo "{\"requests\":[{\"image\":{\"content\":\"$BASE64_IMAGE\"},\"features\":[{\"type\":\"TEXT_DETECTION\",\"maxResults\":4}]}]}" > gcv_ocr_request.json

google vision api, , curl repose json :

curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=$GCV_API_KEY --data-binary @gcv_label_request.json > gcv_label_response.json

google vision api, , curl repose json :

curl -v -k -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=$GCV_API_KEY --data-binary @gcv_ocr_request.json > gcv_ocr_response.json
0

You can go to https://console.developers.google.com/iam-admin/projects and make your project.

After that, just turn on the service you want. Just make sure you keep the key in a safe place. This is a simple step to help you enable the service.

In addition to ensuring that your project is authenticated and authorized to see, just follow the next step.

https://googlecloudplatform.imtqy.com/google-cloud-python/stable/google-cloud-auth.html

0
source

Source: https://habr.com/ru/post/1629742/


All Articles