Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

2 minor code changes #65

Open
wants to merge 3 commits into from

2 participants

@gidzone

fixed issue #20 to return results to support more than just access_token and refresh token
Made a change to handle 302 responses like 200

gidzone added some commits
@gidzone gidzone issue #20: returned results to the callback along with access_token a…
…nd refresh_token

Other implementations return more than just access_token and the
refresh_token.  For example, salesforce returns the instance url.
dc0b92c
@gidzone gidzone Handle the 302 response like the 200.
Salesforce returns at 302 with its oath flow.  Handle the 302 status
code like the 200.
2be7086
@ciaranj
Owner

looks good, I guess there should be a delete results["access_token"] in there as well now we're actually passing that literal back to the consumer (tbh I'm not sure why the delete results["refresh_token"] is in there, but its always good to be consistent!

If you wouldn't mind adjusting that i'll gratefully/happily pull in both your submitted commits ? :)

Thanks!

@gidzone gidzone added delete results["access_token"];
added delete results["access_token"];

Added delete results["access_token"]; to stay consistent with delete
results["refresh_token"];
ebd5561
@gidzone

Should be good to go.

thanks!

-sanjay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 1, 2011
  1. @gidzone

    issue #20: returned results to the callback along with access_token a…

    gidzone authored
    …nd refresh_token
    
    Other implementations return more than just access_token and the
    refresh_token.  For example, salesforce returns the instance url.
  2. @gidzone

    Handle the 302 response like the 200.

    gidzone authored
    Salesforce returns at 302 with its oath flow.  Handle the 302 status
    code like the 200.
Commits on Sep 5, 2011
  1. @gidzone

    added delete results["access_token"];

    gidzone authored
    added delete results["access_token"];
    
    Added delete results["access_token"]; to stay consistent with delete
    results["refresh_token"];
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/oauth2.js
View
8 lib/oauth2.js
@@ -64,7 +64,8 @@ exports.OAuth2.prototype._request= function(method, url, headers, post_body, acc
function passBackControl( response, result ) {
if(!callbackCalled) {
callbackCalled=true;
- if( response.statusCode != 200 ) {
+ //handle 302 responses like 200
+ if( response.statusCode != 200 && response.statusCode != 302) {
callback({ statusCode: response.statusCode, data: result });
} else {
callback(null, result, response);
@@ -135,8 +136,11 @@ exports.OAuth2.prototype.getOAuthAccessToken= function(code, params, callback) {
}
var access_token= results["access_token"];
var refresh_token= results["refresh_token"];
+ delete results["access_token"];
delete results["refresh_token"];
- callback(null, access_token, refresh_token);
+
+ //passing results to the callback as other implementations return additional information
+ callback(null, access_token, refresh_token, results);
}
});
}
Something went wrong with that request. Please try again.