What causes intermittent Invalid Grant

霸气de小男生 提交于 2019-12-11 10:41:40

问题


I'm getting the following

{
  "error" : "invalid_grant"
}
    at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:103)
    at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:303)
    at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.execute(GoogleRefreshTokenRequest.java:130)

This only happens in my production Appengine instance, (ie. not on dev server), and it only happens for the email address that I use for testing on both dev and production.

My working hypothesis is that it is something to do with the user being granted a refresh-token on the dev server which is somehow interfering with the stored refresh-token on the prod server.

Can anybody confirm this explanation, and is there a best practice on how to deal with this exception?


回答1:


Currently only the last 25 refresh tokens granted by Google work. We basically keep a queue of size 25 of generated refresh tokens.

That mean that on your testing account if you happened to generate more than 25 refresh tokens the older ones will start to be revoked.

Maybe that is what is happening here so I wanted to point this out, it could be that you generated more than 25 refresh tokens on your dev server with your test account and the token that was in prod got dropped (because there are 25 newer ones).

That is something that is not documented about our authentication servers and as such be aware that it could change anytime.

In general when this exception happens you need to make the user go through a new OAuth 2.0 flow in order to get a new refresh token.



来源:https://stackoverflow.com/questions/12549088/what-causes-intermittent-invalid-grant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!