code: function(req, res, next) {
      var accessTokenUrl = 'https://github.com/login/oauth/access_token';
      var params = {
        code: req.body.code,
        client_id: req.body.clientId,
        client_secret: config.GITHUB_SECRET,
        redirect_uri: req.body.redirectUri
      };
  
      request.get({ url: accessTokenUrl, qs: params }, function(err, response, accessToken) {
        if (err) {
          res.status(500).send(err);
          return;
        }
        req.accessToken = qs.parse(accessToken);
        next();
      });
    }
docs: Step 1. Exchange authorization code for access token.