Fixes issue 17 - Handles rev07 and above of the OAuth spec
This commit is contained in:
@ -87,7 +87,19 @@ exports.OAuth2.prototype.getOAuthAccessToken= function(code, params, callback) {
|
||||
this._request("POST", this._getAccessTokenUrl(params), {}, null, function(error, data, response) {
|
||||
if( error ) callback(error);
|
||||
else {
|
||||
var results= querystring.parse(data);
|
||||
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
|
||||
results= querystring.parse( data );
|
||||
}
|
||||
var access_token= results["access_token"];
|
||||
var refresh_token= results["refresh_token"];
|
||||
delete results["refresh_token"];
|
||||
|
Reference in New Issue
Block a user