Vision client does not support api-key

It seems that the Python client to view the Google cloud (google.cloud.vision.client.Client) is not able to accept api-key.

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

How can I use client with api-key authentication?

+7
python google-cloud-vision
source share
1 answer

I am only adding this for future readers, because there is no other answer now (I also added generosity):

from googleapiclient.discovery import build # ... service = build('vision', 'v1', developerKey=API_KEY, cache_discovery=False) image_b64 = base64.b64encode(image_bytes).decode() return service.images().annotate(body={ 'requests': [{ 'image': { 'content': image_b64 }, 'features': [{ 'type': 'DOCUMENT_TEXT_DETECTION', 'maxResults': 5, }] }] }).execute() 

This (python) sample, obviously, does not use the client in question, but that’s exactly how I started working on it now to make a simple OCR.

You can change the features or specification of the image to suit your needs.

+1
source share

All Articles