zakariachowdhury / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

NullPointerException if invalid client authentification #907

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.15.0-rc)?
1.19.0

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Native Java 8

Describe the problem.
If the client authentification is invalid and the server responds only with a 
401 error without other content in the response, a NPE is thrown. It's not 100% 
clear in the spec, if the server HAVE TO respond with a specific error message 
in the body or not, so it would be better to assume that it have not.
http://tools.ietf.org/html/rfc6749#section-5.2

How would you expect it to be fixed?
Generate an "invalid_client" exception, if the server only responds with a 401 
error and skip the body parsing, if no body.

Original issue reported on code.google.com by s.vo...@itsonix.eu on 6 Oct 2014 at 1:35

GoogleCodeExporter commented 9 years ago
Some more information:

Do catch the NPE we need to check, if the response.getContent() is null in 
TokenResponseException#from - Line 88

The origin of this bug is in NetHttpResponse#getContent which doesn't return 
the content of the response.
Although there is this json below, it returns <null>.

Best regards 

{"error":"invalid_token","error_description":"Invalid refresh token: 
eyJhbGciOiJub25lIn0.eyJqdGkiOsdfsdfiI0MzVjYmU5OC05MzEwLTQ5NDItYjgzZS0yNDgxOWMxMj
I2YzUifQ."}

Original comment by s.vo...@itsonix.eu on 19 Dec 2014 at 7:30

GoogleCodeExporter commented 9 years ago
Moved to: Issue google-oauth-java-client:100

Original comment by wonder...@google.com on 29 Dec 2014 at 7:17