Skip to content

Instantly share code, notes, and snippets.

@bytespider
Created September 1, 2011 16:41
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytespider/1186612 to your computer and use it in GitHub Desktop.
Save bytespider/1186612 to your computer and use it in GitHub Desktop.
jsOAuth xAuth boilerplate
var oauth = OAuth({
consumerKey: 'MY-CONSUMER-KEY',
consumerSecret: 'MY-CONSUMER-SECRET'
});
oauth.post('https://api.twitter.com/oauth/access_token', {
'x_auth_username': 'DarthVader',
'x_auth_password': 'Luk3i5myS0n',
'x_auth_mode': 'client_auth'
}, successCallback, failureCallback);
function successCallback(response)
{
// contain within is a token of joy
var token = oauth.parseTokenRequest(response.text);
var tokenKey = token.oauth_token;
var tokenSecret = token.oauth_token_secret;
oauth.setAccessToken(tokenKey, tokenSecret);
// launch the rest of my application
app.nowHasTokenCode();
}
function failureCallback(response)
{
console.error('Something bad happened', response.text);
}
@huylenq
Copy link

huylenq commented Dec 18, 2012

Is this still relevant? I can't make it working.

@bytespider
Copy link
Author

Yes I believe it should still work unless twitter has changed something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment