Cloud Vision API permission denied

I tried to run the sample application found here The Github example , I created a certificate and created an API key and applied it according to the instructions, But when I load the image, I get this exception. I do not know where I was wrong. Did I miss something?

failed to make API request because { "code": 403, "errors": [{ "domain": "global", "message": "Requests from this Android client application <empty> are blocked.", "reason": "forbidden" }], "message": "Requests from this Android client application <empty> are blocked.", "status": "PERMISSION_DENIED" } 
+7
android google-cloud-platform google-cloud-vision
source share
5 answers

I had the same problem. but I solve it.

If you add a browser API key, your code will work well.

+4
source share

I suspect that you are creating an Android API key limited to your application with a registered sha1 fingerprint.

It's great! Unfortunately, the non-Android client API library of the Google API does not yet fully support API requests for android api keys, for example, specific for Android . This means that the API requests do not include some headers that authenticate the key / application for the API endpoint, which causes this error (note the client application <empty> in the error message - <empty> will be your package name if the request was formed as expected).

I'm still looking for what to do with it - will update when / when I find it.

+5
source share

What have you changed in the Android project? Make sure you enable the cloud vision API and enable billing. All I had to do was add my API key to MainActivity using the same sample from Github.

Take a look at the screenshot

0
source share

some kind of problem and i will fix it !!!!!

just enter the server key!

enter image description here

hope this helps someone

0
source share

I believe that using a browser key will solve your problem. But the actual solution to this is to use the OAuth key. Like the Android app.

  • To do this, go to the credentials section from the side menu in the Cloud Developer Console.
  • Click the credentials pop-up menu and select OAuth Client ID.
  • Select an application type as Android.
  • Add a suitable name, such as the Android client for the Cloud Vision API.
  • Enter your SHA1 fingerprint in the desired format. Using indicated on the screen.
  • Enter the package name for your application, which can be found in the defaultConfig block of your gradle.
  • Click the create button.

This is an excerpt from the full tutorial here .

0
source share

All Articles