Created
April 3, 2015 21:47
-
-
Save JonnyBurger/c2b3cab22feebef433b9 to your computer and use it in GitHub Desktop.
This file contains 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
this._request("POST", this._getAccessTokenUrl(), post_headers, post_data, null, function(error, data, response) { | |
if( error ) callback(error); | |
else { | |
var results; | |
try { | |
// As of http://tools.ietf.org/html/draft-ietf-oauth-v2-07 | |
// responses should be in JSON | |
results= JSON.parse( data ); | |
} | |
catch(e) { | |
// .... However both Facebook + Github currently use rev05 of the spec | |
// and neither seem to specify a content-type correctly in their response headers :( | |
// clients of these services will suffer a *minor* performance cost of the exception | |
// being thrown | |
console.log('trying to parse querystring') | |
results= querystring.parse( data ); | |
} | |
//if (!results) { | |
// results = querystring.parse(data) | |
//} | |
var access_token= results["access_token"]; | |
var refresh_token= results["refresh_token"]; | |
delete results["refresh_token"]; | |
callback(null, access_token, refresh_token, results); // callback results =-= | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment