-
Notifications
You must be signed in to change notification settings - Fork 701
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
Method Credential.refreshToken calls TokenResponseException.from which throws NullPointerException #904
Comments
From y.c...@appresso.com on December 02, 2014 04:42:44 This problem also occurs in 1.19.0. I have tried several error cases and found that this problem occurs in following situations:
Just FYI. |
From ben.gilb...@smartsheet.com on December 03, 2014 13:44:42 We run into this error all the time when we're trying to obtain a service account credential using refreshToken(). The token endpoint ( https://accounts.google.com/o/oauth2/token ) properly returns a 401 error if we can't obtain a service account credential for the user, but the TokenResponseException.from() promptly blows up because the 401 response doesn't have any content. For now we are trapping the NullPointerException explicitly, but I agree with the original bug - the underlying HTTP error should be returned cleanly rather than throwing a NPE. |
From premna...@gmail.com on December 16, 2014 05:40:53 I am trying to connect to the GMAIL using service account to list my emails and I am getting the same error. I am using the 1.19.0 clients. Please advise. java.lang.NullPointerException |
From rajesh.s...@gmail.com on December 17, 2014 02:20:55 I am getting the following exception when i access using service account for Prediction API. I am using 1.19.0 java client api. I changed and tried with new p12 keys , but nothing worked. java.lang.NullPointerException: null |
From KoichiSe...@gmail.com on December 17, 2014 02:29:51 The bug method TokenResponseException is here. https://code.google.com/p/google-oauth-java-client/source/browse/google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/TokenResponseException.java Can we submit a fixed file into the sources? |
From rajesh.s...@gmail.com on December 18, 2014 06:38:16 Hi, credential = new GoogleCredential.Builder().setTransport(httpTransport).setJsonFactory(JSON_FACTORY) Regards, |
From tharshan...@gmail.com on December 22, 2014 17:04:53 Hi, I get this error after receiving "Authorization Code" 199.74.155.50 - - [22/Dec/2014:19:29:44 +0000] "GET /Hello-JSP/ObtainOAuth2Token HTTP/1.1" 302 - Thanks |
From g.dilemb...@gmail.com on December 26, 2014 05:18:32 hi i m trying to access google drive using sample DriveSample offered by google.But i got same npe as above: CONFIG: -------------- RESPONSE -------------- java.lang.NullPointerException Any hint? |
From KoichiSe...@gmail.com on December 26, 2014 22:23:20 There is clearly a bug in the com.google.api.client.auth.oauth2.TokenResponseException.from method code. https://code.google.com/p/google-oauth-java-client/source/browse/google-oauth-client/src/main/java/com/google/api/client/auth/oauth2/TokenResponseException.java It just does not check the response.getContent() return value for null before calling the com.google.api.client.json.JsonObjectParser.parseAndClose method with it. https://code.google.com/p/google-http-java-client/source/browse/google-http-client/src/main/java/com/google/api/client/json/JsonObjectParser.java Only the last method com.google.api.client.json.jackson2.JacksonFactory.createJsonParser does the check for null, which is already too late, and so it throws the NullPointerException. https://code.google.com/p/google-http-java-client/source/browse/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java I guess the code should just check for null in the TokenResponseException.from method itself in the "if" section. I will most likely get my hands on doing that myself some day soon if the original code developers will not fix it before. |
From wonder...@google.com on December 29, 2014 11:48:07 Status: Duplicate |
From wonder...@google.com on December 29, 2014 11:53:58 There has been a fix for this issue and it's currently under review because of the holidays. This change will go in to the default branch once it's reviewed, and will be live for all APIs in the next release. |
From jonathan...@gmail.com on January 03, 2015 18:43:03 What is the workaround for this? I'm doing user impersonation with offline access (long-lived tokens), and I'm constantly having to ask users to re-authorize (sort of defeats the point of offline access) because I can't get a new access token with refreshToken(). |
Fixes #904 Source-Author: Neenu Shaji <Neenu1995@users.noreply.github.com> Source-Date: Wed Mar 24 15:50:02 2021 -0400 Source-Repo: googleapis/synthtool Source-Sha: bb854b6c048619e3be4e8b8ce8ed10aa74ea78ef Source-Link: googleapis/synthtool@bb854b6
From KoichiSe...@gmail.com on September 18, 2014 05:36:30
Version of google-api-java-client (e.g. 1.15.0-rc)? 1.18.0-rc Java environment (e.g. Java 6, Android 2.3, App Engine)? Java 1.7.0_55-b13 on Linux Gentoo 3.12.20 Describe the problem. java.lang.NullPointerException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at com.google.api.client.util.Preconditions.checkNotNull(Preconditions.java:127)
at com.google.api.client.json.jackson2.JacksonFactory.createJsonParser(JacksonFactory.java:96)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:85)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81)
at com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:88)
at com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.api.client.auth.oauth2.Credential.executeRefreshToken(Credential.java:570)
at com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:247)
at com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489) How would you expect it to be fixed? Surely there has to be a cutomized runtime exception instead of NPE to figure out the cause.
Original issue: http://code.google.com/p/google-api-java-client/issues/detail?id=904
The text was updated successfully, but these errors were encountered: