The API key is invalid when trying to access the cloud-based vision of Google api

I am trying to check the vision API and uploaded some images to Google Cloud Storage and created a browser application that requests a cloud api to process them.

I have a client_id file that I downloaded from the Google developer console. This has a client_id value, which I use as my api key.

I'm making a request

https://content-vision.googleapis.com/v1/images:annotate?alt=json&key=414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com

(changed api key)

and publish the request:

 { "requests": [ { "image": { "source": { "gcsImageUri": "https:\/\/console.cloud.google.com\/m\/cloudstorage\/b\/estoril_test\/o\/AI4C3160.JPG" } }, "features": [ { "type": "LABEL_DETECTION", "maxResults": 1 } ] } ] } 

but I get an error:

 { "error": { "code": 400, "message": "API key not valid. Please pass a valid API key.", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.rpc.Help", "links": [ { "description": "Google developer console API key", "url": "https://console.developers.google.com/project/414754136843/apiui/credential" } ] } ] } } 

I have authorized the api key for cloud view api, so what am I doing wrong? I tried an example of twisting in a demo, but I keep getting

Protocol https not supported or disabled in libcurl

I tried adding double quotes, as some research I suggested, but still no luck.

+5
source share
4 answers

If the problem with the "API key is not valid", it looks like you are using the server key, but you need to use the browser key. The Vision API Getting Started page provides detailed screenshots, as well as an example of twisting.

The second problem you are likely to encounter is the incorrect gcsImageUri format. According to the Vision API reference documents , the image URI should be in the form "gs: // bucket_name / object_name", so in your case: something like: "gs: //storil_test/AI4C3160.JPG"

+4
source

Another problem that KEY may encounter does not work, is that the specific service was not added to the project you are trying to work with. This will give the same answer.

+2
source

The problem is resolved.

After creating the credentials, click "Create Credentials" and select "API Key"; the generated API key will be created.

+1
source

key = 414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com

This is the Oauth Client ID key.

 sAjnhsejklfynGiuhYGBYUGDYGziodzdCfhAO7qPY 

This is an example of a valid API key.

To create the KEY API, follow this link: https://support.google.com/cloud/answer/6158862?hl=en

0
source

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


All Articles