Search code examples
pythonwindowsgoogle-cloud-platformcentosvirtualbox

invalid JWT error with timeframe using google-cloud-vision api on virtual windows


I installed windows7 on the virtualbox to use google-cloud-vision api on the activeX web page on my CentOS server.

Using google-cloud-vision API for authentication, following error during authentication:

google.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: ('invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values and use a clock with skew to account for clock differences between systems.')

Windows Internet Time Sync, time is synchronized, but an error occurs. but same code on normal Windows, no error occurs.

client = vision.ImageAnnotatorClient()

imgByteArr = io.BytesIO()
textImage.save(imgByteArr, format='PNG')
content = imgByteArr.getvalue()

image = types.Image(content=content)

response = client.text_detection(image=image)
labels = response.text_annotations
print(labels[0].description)

Solution

  • Troubleshooting: Reset host os time (set NTP)

    problem was the time difference between host os and guest os.

    ln -sf / usr / share / zoneinfo / Asia / Seoul / etc / localtime
    rdate -s time.bora.net
    hwclock --systohc
    date
    hwclock
    

    At time.bora.net, find and configure the appropriate ntp(network time protocol) server. Fit your area