code: function connect (conf) {
    // Instantiating API client, this is the one that will be passed to other methods
    var client = new Client();
  
    if (conf["my-host.token"]) {
      // Authorize client
      client.setToken(conf["my-host.token"]);
      // Check token…
      return checkToken(client)
        .then(null, function () {
          // …and create a new one if it failed
          console.error("Existing token is invalid");
          return createToken(client);
        });
    } else {
      // No token found: create new one
      return createToken(client);
    }
  }
docs: Assuming client.setToken sets authorization token for next calls