Skip to content

No timeout in getUserInfo Function. #381

@devchanki

Description

@devchanki

src/ApiClient

version: 5.9.0-rc1

` exports.prototype.getUserInfo = function(accessToken, callback) {
if(!accessToken) throw new Error('Error accessToken is required',null);

var headers = {
  "Authorization": "Bearer " + accessToken,
  "Cache-Control": "no-store",
  "Pragma": "no-cache"
}

var request = superagent.get("https://" + this.getOAuthBasePath() + "/oauth/userinfo").set(headers);
var UserInfo = require('./OAuth').UserInfo;

if(!callback) {
  try {
    return new Promise(function (resolve, reject) {
      request.end(function (err, res) {
        if (err) {
          reject(err);
        } else {
          try {
            resolve(UserInfo.constructFromObject(res.body));
          } catch (error) {
            reject(error);
          }
        }
      });
    });
  } catch (err) {
    throw(err)
  }
} else {
  request.end(function (err, res) {
    if (err) {
      return callback(err, res);
    } else {
      return callback(err, UserInfo.constructFromObject(res.body));
    }
  });
}

};`

The timeout setting is not respected by some helper methods that make direct superagent calls instead of using the callApi wrapper. A clear example is the ApiClient.prototype.getUserInfo method, which does not provide a timeout option.

Some helper methods bypass the callApi wrapper and make direct superagent requests. For example, ApiClient.prototype.getUserInfo does not accept a timeout parameter, so the global timeout setting has no effect. If there is a way to set a timeout here, I would appreciate guidance.

thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions