prose / gatekeeper

Enables client-side applications to dance OAuth with GitHub.
MIT License
760 stars 182 forks source link

authenticate functions swallows errors from github #36

Open kriswep opened 6 years ago

kriswep commented 6 years ago

While working on #35 i noticed, the actual request callback implementation in authenticate functions swallows quite a lot of errors returned by gihub. Eg. when providing a bad code, res.on('end', ..) will be called and just returns an empty error obejct and an null token.

Only way I could get actual errors was when the request timed out.

// .. Relevant code in authenticate function in server.js
  var req = https.request(reqOptions, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) { body += chunk; });
    res.on('end', function() {
      cb(null, qs.parse(body).access_token);
    });
  });
//..