I upgraded to version 1.0a and when revoking permission I have been
receiving the following error when attempting to authorized access
token
Caused by: java.io.IOException: Server returned HTTP response
code: 400 for URL
This declared on
http://code.google.com/apis/accounts/docs/OAuth_ref.html
Note: The return of a verification code does not indicate that a
request token has been authorized. If a request token has not been
authorized, then requests to exchange it for an access token will
fail.
However, instead of getting the response content ("The request token
is invalid.") which can be acquired by manually trying out the request
URL in a browser OAuthHttpClient.getResponse() instead throws the
IOException above with the 400 code leaving the developer to fumble
and debug.
After finding the following link
http://www.coderanch.com/t/433447/Streams/java/HttpsURLConnection-Reading-Body-Response-when
I have tried patching with the following
public String getResponse(URL url) throws OAuthException {
try {
HttpURLConnection connection = (HttpURLConnection)
url.openConnection();
connection.connect();
InputStream _is;
if (connection.getResponseCode() < 400) {
_is = connection.getInputStream();
} else {
/* error from server */
_is = connection.getErrorStream();
}
BufferedReader in = new BufferedReader(new
InputStreamReader(_is));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
if (connection.getResponseCode() >= 400) {
throw new IOException(response.toString());
}
return response.toString();
} catch (IOException e) {
throw new OAuthException("Error getting HTTP response",
e);
}
}
At least this way you can interrogate the exception to find out what
happened.