Permalink
Browse files

Allowing OAuth communication to return a more restful response object.

  • Loading branch information...
1 parent ef7dd4d commit 3ce8e66cbd3f3c3261339f883dd0e1ee1012d539 Antony Jones committed Aug 24, 2011
@@ -19,7 +19,6 @@ package org.grails.plugins.oauth
import org.springframework.beans.factory.InitializingBean
import org.codehaus.groovy.grails.commons.ConfigurationHolder as C
-import oauth.signpost.OAuth
import oauth.signpost.OAuthConsumer
import oauth.signpost.OAuthProvider
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
@@ -348,12 +347,15 @@ class OauthService implements InitializingBean {
*/
def accessResource(final def Map args) {
final HttpResponse response = doRequest(args)
- String body = ""
+ OauthResponse oauthPacket = new OauthResponse()
try {
log.debug "Reading response body"
- body = EntityUtils.toString(response.getEntity())
+ oauthPacket.with {
+ body = EntityUtils.toString(response.getEntity())
+ status = response.statusCode
+ }
log.debug "Response body read successfully"
@@ -366,7 +368,7 @@ class OauthService implements InitializingBean {
}
// Provide response
- return body
+ return oauthPacket
}
/**
@@ -0,0 +1,8 @@
+package org.grails.plugins.oauth
+
+class OauthResponse {
+
+ int status
+ String body
+
+}

0 comments on commit 3ce8e66

Please sign in to comment.