oauth2client.client.HttpAccessTokenRefreshError:invalid_grant:无效的JWT [英] oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Invalid JWT
问题描述
我在我的Raspberry PI上使用Google Cloud Vision API.当我在家庭网络(首次访问云帐户)上使用它时,它可以正常工作,但是如果我从其他网络访问API,则会引发令牌刷新错误.我已经使用NTP同步了时间,但是没有帮助.
I am using Google Cloud Vision API on my Raspberry PI. It works fine when I use it on my home (on which the cloud account was first accessed) network but if I access the API from a different network it raises a token refresh error. I have synchronized the time using NTP but is of no help.
详细错误:
oauth2client.client.HttpAccessTokenRefreshError:invalid_grant:无效的JWT:令牌必须是短期令牌(60分钟),并且必须在合理的时间范围内.检查您的iat和exp值,并使用带有偏斜的时钟来解决系统之间的时钟差异.
oauth2client.client.HttpAccessTokenRefreshError: 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.
推荐答案
invalid_grant:无效的JWT:令牌必须是短期令牌(60分钟),并且必须在合理的时间范围内.
invalid_grant: Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe.
这是由于执行5分钟或更长时间的代码的计算机时钟同步不良所致.该错误表示令牌无效,并且令牌无效,因为PI上的时间与实际时间不同.我知道您说您正在检查NTP,但我建议您也检查时区.
This is caused by poor synchronisation of the computer's clock where the code was executed that had a lag of 5 minutes or more. The error means that the token is not valid and its not valid because the time on the PI is different then the actual time. I know that you say you are checking NTP but I suggest you check timezone as well.
我知道这是一个PI,因此调试可能受到限制,但是尝试输出您的id令牌并解密其jwt,您应该能够看到iat和exp值.它可以帮助您弄清楚现在是几点.
I know this is a PI so debugging is probably limited but try outputting your id token and decryption its a jwt you should be able to see the iat and exp values. It might help you figure out what time it thinks it is.
这篇关于oauth2client.client.HttpAccessTokenRefreshError:invalid_grant:无效的JWT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!