Reputation: 119
We were able get the data from Google Analytics using Oauth2.0, but now suddenly we are getting 403 User Rate Limit Exceeded and 401 Invalid Credentials.
On server start up we are getting,
SEVERE: unable to refresh token com.google.api.client.auth.oauth2.TokenResponseException: 403 User Rate Limit Exceeded
and for subsequent requests it is giving,
com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized { "code" : 401, "errors" : [ { "domain" : "global", "location" : "Authorization", "locationType" : "header", "message" : "Invalid Credentials", "reason" : "authError" } ], "message" : "Invalid Credentials" }
I have tested access token with following url :
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=xxxxxxxx
I am getting valid access token message, but still i am getting Invalid Credentials. I have also tried with OAuth2 playground, here also i am getting same message.
Any help to resolve this issue.
Upvotes: 2
Views: 1882
Reputation: 932
Make sure you are caching the access tokens and that you are making a reasonable number of refresh requests. Refreshing in a tight loop (or too frequently from multiple threads or servers in a cluster) for the same user will lead to 403.
The 401 error is most likely due to the fact that getting a new access token failed and you are using an expired one.
Upvotes: 2