Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Created September 21, 2010 08:53
Show Gist options
  • Save oberhamsi/589418 to your computer and use it in GitHub Desktop.
Save oberhamsi/589418 to your computer and use it in GitHub Desktop.
var signpost = Packages.oauth.signpost;
// app keys
var CONSUMER_KEY = 'KKKKKKKKKKKKKKKKKEY';
var CONSUMER_SECRET = 'SEEEEEEEEEEEECRET';
// user keys - we got those earlier with provider.retrieveAccessToken
var ACCESS_TOKEN = 'TOOOOOOOOKEN';
var TOKEN_SECRET = 'SEEEEEEEEEECRET';
// create a consumer object and configure it with the access
// token and token secret obtained from the service provider
var consumer = new signpost.jetty.JettyOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
consumer.setTokenWithSecret(ACCESS_TOKEN, TOKEN_SECRET);
// create an HTTP request to a protected resource
var request = new org.eclipse.jetty.client.ContentExchange();
request.setMethod("GET");
request.setURL("http://twitter.com/statuses/mentions.xml");
// sign the request
consumer.sign(request);
// send the request
var client = new Packages.org.eclipse.jetty.client.HttpClient();
client.start();
client.send(request);
request.waitForDone();
print(request.getResponseContent());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment