问题
I am running the Analytics-cmdline-sample application with Java. I am using Maven 2.2.1, I have created a client_Id and client_secret in the Google Api Console. I have ensured that in my Google Analytics account that I have access to the websites I have Google Analytics on.
I have revoked the client_secret and tried that as well.
I am currently getting the following error:
com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant"
}
I have looked through for many solutions to these problems, but I haven't found any solution as of yet that would resolve this error.
回答1:
In my case, the "client_id" was the root of the problem. I add a "short" client_id (xxxxxxxxxxxx.apps.googleusercontent.com). When I created a new "Client ID for web applications" the new client_id was longer (xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com) and the error disappeared.
来源:https://stackoverflow.com/questions/14622344/invalid-grant-in-google-analytics