Skip to content

Commit 3d9d574

Browse files
committed
Log errors encoutered by the OAuth1.0 return web script when attempting to obtain an access token
1 parent e3078d9 commit 3d9d574

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

share-oauth/src/main/java/org/sharextras/webscripts/OAuthReturn.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import org.apache.commons.httpclient.HttpException;
1010
import org.apache.commons.httpclient.HttpMethod;
1111
import org.apache.commons.httpclient.methods.PostMethod;
12+
import org.apache.commons.logging.Log;
13+
import org.apache.commons.logging.LogFactory;
1214
import org.json.JSONException;
1315
import org.json.JSONObject;
1416
import org.json.JSONStringer;
@@ -59,6 +61,8 @@ public class OAuthReturn extends AbstractWebScript
5961
ConnectorService connectorService;
6062
String accessTokenUrl;
6163

64+
private static Log logger = LogFactory.getLog(OAuthReturn.class);
65+
6266
/**
6367
* Web Script constructor
6468
*/
@@ -353,7 +357,17 @@ private Map<String, String> requestAccessToken(
353357
}
354358
else
355359
{
356-
throw new WebScriptException(statusCode, "A problem occurred while requesting the access token");
360+
try
361+
{
362+
byte[] responseBody = method.getResponseBody();
363+
String tokenResp = new String(responseBody, Charset.forName("UTF-8"));
364+
logger.error("Request for access token returned " + statusCode + " response: " + tokenResp);
365+
}
366+
catch (IOException e)
367+
{
368+
369+
}
370+
throw new WebScriptException(statusCode, "A problem occurred while requesting the access token (code " + statusCode + ")");
357371
}
358372
}
359373

0 commit comments

Comments
 (0)