Skip to content

Instantly share code, notes, and snippets.

@geNAZt
Created March 9, 2013 10:37
Show Gist options
  • Save geNAZt/5123785 to your computer and use it in GitHub Desktop.
Save geNAZt/5123785 to your computer and use it in GitHub Desktop.
/**
* Module dependencies.
*/
var util = require('util'),
OAuth2Strategy = require('passport-oauth').OAuth2Strategy,
InternalOAuthError = require('passport-oauth').InternalOAuthError;
function Strategy(options, verify) {
options = options || {};
options.authorizationURL = options.authorizationURL || 'https://stackexchange.com/oauth';
options.tokenURL = options.tokenURL || 'https://stackexchange.com/oauth/access_token';
options.scopeSeparator = options.scopeSeparator || ',';
OAuth2Strategy.call(this, options, verify);
this.name = 'stackexchange';
}
util.inherits(Strategy, OAuth2Strategy);
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.get('https://api.stackexchange.com/2.1/me?site=stackoverflow&key=UzR5Nzu64wCX)VoZ6aNjiA((', accessToken, function (err, body, res) {
if (err) {
return done(new InternalOAuthError('failed to fetch user profile', err));
}
try {
console.log(body);
done(null, {});
} catch(e) {
done(e);
}
});
}
module.exports = Strategy;
@geNAZt
Copy link
Author

geNAZt commented Mar 9, 2013

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