Created
September 21, 2010 08:53
-
-
Save oberhamsi/589418 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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