Created
March 9, 2013 10:37
-
-
Save geNAZt/5123785 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
/** | |
* 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; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NodeJS Output:
http://www7.pic-upload.de/09.03.13/hd6pp2mgffav.png