googleplus/gplus-verifytoken-java — pull request #4 by yunspace (2014-10-19 01:56:23+00:00)
Title: removed unreachable tokeInfo error check block.

The following ` if (tokenInfo.containsKey("error"))` in Verify.java is unreachable and slightly misleading. Because when calling

Tokeninfo tokenInfo = oauth2.tokeninfo().setAccessToken(accessToken).execute()

With an invalid token (such as an expired one), the SDK will always throw an Exception instead of returning a Tokeinfo object:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)

The `GoogleJsonResponseException` is quite understandable. You can verify by calling the API directly without using the SDK: `https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=`. If a invalid/expired token is used, the error response can't be parsed into a Tokeninfo object:

{
error: "invalid_token",
error_description: "Invalid Value"
}

Therefore the developer really shouldn't be checking for errors in the Tokeninfo but instead rely the IOException catch block.