Michael
Michael

Reputation: 1397

Signpost Oauth and post parameters

I am using signpost with google appengine (java) to send a status update to twitter.

OAuthConsumer consumer = new DefaultOAuthConsumer("AAA",
            "BBB");
consumer.setTokenWithSecret("CCC", "DDD");

URL url = new URL("http://api.twitter.com/1.1/statuses/update.json?status=abc");
HttpURLConnection request;
request = (HttpURLConnection) url.openConnection();
consumer.sign(request);
request.setRequestMethod("POST");  

request.connect();
InputStream response = request.getInputStream();
int a = response.read();
while (a!=-1){
    resp.getOutputStream().write(a);
    a = response.read();
    }

You can see hear I am putting the post parameters in the url like a get request, someone else mentioned this worked for them, I have also tried to put them in the body of the message like you are supposed to do. But I always get {"errors":[{"message":"Could not authenticate you","code":32}]}. My tokens and secret tokens are all correct, but if they weren't I would get a different error of {"errors":[{"message":"Invalid or expired token","code":89}]}.

I think signpost isn't doing the oauth process on the whole body (including the parameters) so it is giving the error.

Any ideas?

Upvotes: 0

Views: 295

Answers (1)

Michael
Michael

Reputation: 1397

Turns out signpost is not a great library for app-engine. A few bugs in it prevent it from working without certin errors. Scribe is a better Oauth tool to be used with Appengine Java.

Upvotes: 0

Related Questions