Skip to content

Instantly share code, notes, and snippets.

@kalley
Created May 21, 2013 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kalley/5622702 to your computer and use it in GitHub Desktop.
Save kalley/5622702 to your computer and use it in GitHub Desktop.
Using a passport.js OAuth provider and using its oauth instance to access the API. (I wish there was a better way, but alas, there is not).
// Uses passport-bitbucket
var strategy = new BitbucketStrategy({
consumerKey: BITBUCKET_CONSUMER_KEY,
consumerSecret: BITBUCKET_CONSUMER_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/bitbucket/callback"
},
function(token, tokenSecret, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {
api.setTokens(token, tokenSecret);
return done(null, profile);
});
}
);
// Bitbucket is a light wrapper around the Bitbucket API that I wrote (not even close to complete).
// Any provider that is using passport-oauth (current version: 0.1.15), will have a ._oath property
var api = Bitbucket(strategy._oauth);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment