Skip to content
This repository

2 minor code changes #65

Open
wants to merge 3 commits into from

2 participants

Sanjay Gidwani Ciaran Jessup
Sanjay Gidwani

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
Sanjay Gidwani 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
Sanjay Gidwani 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
Ciaran Jessup
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!

Sanjay Gidwani 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
Sanjay Gidwani

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

Showing 3 unique commits by 1 author.

Sep 01, 2011
Sanjay Gidwani 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
Sanjay Gidwani 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
Sep 05, 2011
Sanjay Gidwani 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. +6 2 lib/oauth2.js
8 lib/oauth2.js
@@ -64,7 +64,8 @@ exports.OAuth2.prototype._request= function(method, url, headers, post_body, acc
64 64 function passBackControl( response, result ) {
65 65 if(!callbackCalled) {
66 66 callbackCalled=true;
67   - if( response.statusCode != 200 ) {
  67 + //handle 302 responses like 200
  68 + if( response.statusCode != 200 && response.statusCode != 302) {
68 69 callback({ statusCode: response.statusCode, data: result });
69 70 } else {
70 71 callback(null, result, response);
@@ -135,8 +136,11 @@ exports.OAuth2.prototype.getOAuthAccessToken= function(code, params, callback) {
135 136 }
136 137 var access_token= results["access_token"];
137 138 var refresh_token= results["refresh_token"];
  139 + delete results["access_token"];
138 140 delete results["refresh_token"];
139   - callback(null, access_token, refresh_token);
  141 +
  142 + //passing results to the callback as other implementations return additional information
  143 + callback(null, access_token, refresh_token, results);
140 144 }
141 145 });
142 146 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.