SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

Detailed error information not returned by OAuthHttpClient in Java client library #189

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call oAuthHelper.getUnauthorizedRequestToken(oAuthParms) with an invalid
consumer secret. (Or really anything that causes a 400 bad request response.)
2. An OAuthException is thrown but the response body is never read/returned.

The OAuthHttpClient should read the HttpURLConnection error stream to get
the response body and return it to the caller either in the error message
or as a property on the OAuthException. Otherwise it is quite hard to
diagnose the exact cause of the 400 Bad Request errors.

This is the same approach done with classes that extend ServiceException
which offer the getResponseBody() method to get the body of any errors
generated in API calls.

Attached file contains a really simple change to OAuthHttpClient to read
the error stream and including it in the error message if an HTTP error
status is returned. A more flexible approach might be to offer it as a
property on OAuthException like ServiceException does.

Original issue reported on code.google.com by todd.fasullo@smartsheet.com on 22 Sep 2009 at 4:34

Attachments:

GoogleCodeExporter commented 9 years ago
I also do believe that this must be fixed. I spent almost two nights trying to 
figure
out what was going on (I was getting error 400 when requesting a token). I was 
only
able to discover what the problem was (invalid timestamp) after using a code 
snippet
of the class attached by Todd.

Original comment by mfernand...@gmail.com on 24 Jan 2010 at 6:31