This repository was archived by the owner on Feb 13, 2024. It is now read-only.
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT Signature.', '{"error":"invalid_grant","error_description":"Invalid JWT Signature."}') #23
Closed
Description
google-api-core 1.17.0
google-auth 1.14.1
google-cloud-vision 1.0.0
python 3.6.9
and my os is ubuntu 18.04
i am trying to extract text from images
while i am running this code
`import` os, io
from google.cloud import vision
import pandas as pd
from google.oauth2 import service_account
credentials = service_account.Credentials. from_service_account_file('silver-catwalk-276005-0d6c98a26db3.json')
client = vision.ImageAnnotatorClient(credentials=credentials)
file_name = 'img0.jpg'
image_path = f'/home/apiiit-rkv/Desktop/Task, I CAN/codes/{file_name}'
with io.open(image_path, 'rb') as image_file:
content = image_file.read()
image = vision.types.Image(content=content)
response = client.text_detection(image=image) # returns TextAnnotation
df = pd.DataFrame(columns=['locale', 'description'])
texts = response.text_annotations
for text in texts:
df = df.append(
dict(
locale=text.locale,
description=text.description
),
ignore_index=True
)
print(df['description'][0])
it throwing this error
Traceback (most recent call last):
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
return callable_(*args, **kwargs)
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/grpc/_channel.py", line 826, in __call__
return _end_unary_response_blocking(state, call, False, None)
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT Signature.', '{"error":"invalid_grant","error_description":"Invalid JWT Signature."}')"
debug_error_string = "{"created":"@1588564948.414167046","description":"Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT Signature.', '{"error":"invalid_grant","error_description":"Invalid JWT Signature."}')","file":"src/core/lib/security/credentials/plugin/plugin_credentials.cc","file_line":79,"grpc_status":14}"
>
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "first_project_googleVision.py", line 30, in <module>
response = client.text_detection(image=image) # returns TextAnnotation
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/cloud/vision_helpers/decorators.py", line 101, in inner
response = self.annotate_image(request, retry=retry, timeout=timeout)
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/cloud/vision_helpers/__init__.py", line 72, in annotate_image
r = self.batch_annotate_images([request], retry=retry, timeout=timeout)
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/cloud/vision_v1/gapic/image_annotator_client.py", line 274, in batch_annotate_images
request, retry=retry, timeout=timeout, metadata=metadata
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
return wrapped_func(*args, **kwargs)
File "/home/apiiit-rkv/.local/lib/python3.6/site-packages/google/api_core/grpc_helpers.py", line 59, in error_remapped_callable
six.raise_from(exceptions.from_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT Signature.', '{"error":"invalid_grant","error_description":"Invalid JWT Signature."}')
please help me to solve this error