Search code examples
google-cloud-visiongoogle-apis-explorer

google cloud vision api quickstart error opening file


I am following the following Google Cloud Vision quickstart:
https://cloud.google.com/vision/docs/quickstart
This is using the API Explorer, and I get

Error Opening File

I have created a bucket named vision2018, and checked Share Publicly for the file. My portion of the request related to the file is:

"image":
{
"source":
{
"imageUri":"gs://vision2018/demo-image.jpg"
}
}

The response I get is:

{
 "responses": [
  {
   "error": {
    "code": 5,
    "message": "Error opening file: gs://vision2018/demo-image.jpg\"."
   }
  }
 ]
}

}

What do I need to specify in order to access files in my GCP storage?

Alternatively, I read other Stack Overflows that talk about GOOGLE_APPLICATION_CREDENTIALS, Simple API Key, and "Create Service account key and download the key in JSON format", ... but these seem to be giving commands in the shell, which this quickstart doesn't even open. Is there initial setup assumed prior to the quickstart?

I am not ready to call the api from code


Solution

  • You might want to doublecheck your request. I went to the quickstart, replaced the placeholder imageUri with gs://vision2018/demo-image.jpg and it worked just fine. The error message you posted is what would be displayed if you had given gs://vision2018/demo-image.jpg\" instead.

    Regarding the second part of your question: these are authentication methods. In this particular case, under Authentication you will find a drop down which lets you chose between API key and Google OAuth 2.0. If you chose the former, you don't need to do anything as a demo key will be used just for the purposes of the quickstart. If you chose OAuth 2.0, a popup will appear prompting you to authenticate with a google account. All in all, what you need to do is follow step-by-step the instructions given by the quickstart.