I am trying to test out the vision API and have uploaded some images to Google cloud storage and have created a browser app that requests the cloud api to process them.
I have a client_id file that I downloaded from the Google developers console. This has a client_id value that I am using as my api key.
I make a request to
https://content-vision.googleapis.com/v1/images:annotate?alt=json&key=414712345643-cln7htsuv78jr9i64v8v7g6cnhm3ccff.apps.googleusercontent.com
(api key altered)
and post 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 that api key for the cloud vision api so what am I doing wrong? I did try the curl example in the demo but I keep getting
Protocol https not supported or disabled in libcurl
I tried adding double quotes as some research suggested I should but still no luck.
For the "API key not valid" issue, it appears that you are using a Server key, but you need to use a browser key. The Vision API Getting Started page has detailed screenshots, as well as a curl example.
The second issue you are likely to encounter is that the gcsImageUri
is the incorrect format. According to the Vision API reference docs the image URI must be in the form "gs://bucket_name/object_name", so in your case: something like: "gs://storil_test/AI4C3160.JPG"