Skip to content
This repository has been 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
sowmyakavali opened this issue May 4, 2020 · 4 comments
Assignees
Labels
api: vision Issues related to the googleapis/python-vision API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@sowmyakavali
Copy link

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

@plamut plamut transferred this issue from googleapis/google-cloud-python May 4, 2020
@product-auto-label product-auto-label bot added the api: vision Issues related to the googleapis/python-vision API. label May 4, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels May 4, 2020
@munkhuushmgl munkhuushmgl self-assigned this May 11, 2020
@munkhuushmgl
Copy link
Contributor

@sowmyakavali I was able to use your code to produce the correct results without using panda

I think it is an issue with your JWT or key that you are using.

Also, check your system clock.

import os
import io
from google.cloud import vision
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file('/Users/user/Downloads/your-project-service-account.json')
client = vision.ImageAnnotatorClient(credentials=credentials)
image_path = f'detect/resources/text.jpg'

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
texts = response.text_annotations
for text in texts:
    print(text)

image

@munkhuushmgl
Copy link
Contributor

@sowmyakavali
Copy link
Author

this problem is solved
The vision api took time to activate my project that's it
Thank you

@vamshi-7
Copy link

vamshi-7 commented Feb 3, 2021

I didn't use the vision API for 2 months. So I redownloaded the JSON key, and it is working now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: vision Issues related to the googleapis/python-vision API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

4 participants