[groovy-user] Problem with RESTClient oauth feature

59 views
Skip to first unread message

Anand Bhagwat

unread,
Feb 24, 2011, 5:30:18 AM2/24/11
to us...@groovy.codehaus.org
Hi,
I am using below code to access twitter rest api.

        RESTClient restClient = new RESTClient('https://twitter.com/statuses/' )
        restClient.setProxy proxyHost, proxyPort, "http"
        restClient.auth.oauth config.twitter.consumerKey, config.twitter.consumerSecret, accessToken, accessTokenSecret

        def resp = restClient.get(path : 'public_timeline.json')
        resp.getData()


But I am getting following stacktrace.

Stacktrace follows:
java.lang.ClassCastException: org.apache.http.message.BasicHttpRequest cannot be cast to org.apache.http.client.methods.HttpUriRequest
    at groovyx.net.http.AuthConfig$OAuthSigner.process(AuthConfig.java:155)
    at org.apache.http.protocol.BasicHttpProcessor.process(BasicHttpProcessor.java:251)
    at org.apache.http.protocol.HttpRequestExecutor.preProcess(HttpRequestExecutor.java:168)
    at org.apache.http.impl.client.DefaultRequestDirector.createTunnelToTarget(DefaultRequestDirector.java:780)
    at org.apache.http.impl.client.DefaultRequestDirector.establishRoute(DefaultRequestDirector.java:685)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:421)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
    at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:460)
    at groovyx.net.http.RESTClient.get(RESTClient.java:118)
    at hello.TwitterOperations.getProfileId(TwitterOperations.groovy:42)
    at hello.SocialOperations$getProfileId.call(Unknown Source)
    at hello.SocialController$_closure3.doCall(SocialController.groovy:70)
    at hello.SocialController$_closure3.doCall(SocialController.groovy)
    at org.grails.jaxrs.web.JaxrsFilter.doFilterInternal(JaxrsFilter.java:46)
    at java.lang.Thread.run(Thread.java:619)

Any idea as to what is wrong here? I am using following dependencies in my grails project.

        compile 'oauth.signpost:signpost-core:1.2.1.1'
        compile('org.openid4java:openid4java:0.9.5') {
            excludes "xml-apis"
        }
        compile('org.codehaus.groovy.modules.http-builder:http-builder:0.5.1')
        compile('org.scribe:scribe:1.0.6')
        runtime('oauth.signpost:signpost-commonshttp4:1.2.1.1')


Regards,
Anand.

Thom Nichols

unread,
Feb 24, 2011, 1:53:10 PM2/24/11
to user, Anand Bhagwat
It looks like it's because your request is being redirected and the intermediate BasicHttpRequest isn't what I'm expecting.  Interesting... Can you open an issue here:
http://jira.codehaus.org/browse/GMOD
and assign it to the HttpBuilder component?

I'll get it fixed in 0.5.2.

Thanks.
-Thom
Reply all
Reply to author
Forward
0 new messages