New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException processing GoogleRefreshTokenRequest #932
Comments
I added logging to com.google.api on DEBUG level and see "HTTP/1.1 401 Unauthorized" response with empty body returned. This definitely needs to be fixed to produce more sensible exception, since NPE usually indicate an issue with the library in this case. |
This is a duplicated issue and a fix is checked in: The next release, which is under way, will have the fix. For the interim, you could build the libraries from HEAD. |
Thank you, @wonderfly ! Is there any timeline to release the new version? |
It's scheduled next week. On Wed, Mar 11, 2015 at 10:08 PM, Artem Golubev notifications@github.com
Best, |
🎆 👯 |
Hello, I use version 1.20 now, but always have such erreur when refreshToken : com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized |
That could be caused by many things: invalid client ID, client secret or https://developers.google.com/accounts/docs/OAuth2#basicsteps How often do you send refreshToken requests and how often do you get 401s? On Mon, Mar 23, 2015 at 9:59 AM, dc notifications@github.com wrote:
Best, |
@wonderfly I am seeing the same error as @aerodc. I am using v2-rev165-1.20.0. I know for sure that this is not a client ID problem, nor a client secret problem, because I can perfectly reproduce cases where I get the 401 and cases where I don't. Cases where I get the 401 go something like this:
However, if I do things slightly differently, I can avoid the 401 altogether:
I have tracked this behavior down to the same exception that aerodc was seeing: I don't know why Google's servers are giving back a 401. I know that my client ID and secret are correct, because I am able to make some calls (as in the second scenario) without getting a 401. I don't think the problem has anything to do with refreshToken requests either; I am not explicitly requesting refresh tokens outside of whatever the Java client does automatically, and my code's behavior between the two scenarios doesn't change. Am I doing something wrong with scopes, then? I know it's not the Java client's fault, per se - I'm quite happy that the exception is no longer just a NullPointerException. But I wish the Google servers would actually send an explanatory response body to begin with. That would help me understand what I'm doing wrong, as well as solving the NullPointerException problem indirectly. I feel like the fix to the NullPointerException is only half a fix; we simply have exchanged one exception type for another. |
This issue may no longer be relevant due to its age. Feel free to re-open. |
java.lang.NullPointerException: null
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191) ~[google-http-client-1.19.0.jar:1.19.0]
at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127) ~[google-http-client-1.19.0.jar:1.19.0]
at com.google.api.client.json.jackson2.JacksonFactory.createJsonParser(JacksonFactory.java:92) ~[google-http-client-jackson2-1.19.0.jar:1.19.0]
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:85) ~[google-http-client-1.19.0.jar:1.19.0]
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81) ~[google-http-client-1.19.0.jar:1.19.0]
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:88) ~[google-oauth-client-1.19.0.jar:1.19.0]
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287) ~[google-oauth-client-1.19.0.jar:1.19.0]
at com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest.execute(GoogleRefreshTokenRequest.java:125) ~[google-api-client-1.19.1.jar:1.19.1]
The text was updated successfully, but these errors were encountered: