docs: function(task, callback) {
              callback = callback || function() {};
  
              var that = this;
              var req = null;
  
              // This is the callback that will be invoked
              // if we are currently logged in but our session key
              // expired (i.e. we get a 401 response from the server).
              // We will only retry once.
              var reloginIfNecessary = function(err) {
                  // If we aborted, ignore it
                  if (req.wasAborted) {
                      return;
                  }
  
                  if (err && err.status === 401 && that._shouldAutoLogin()) {
                      // If we had an authorization error, we'll try and login
                      // again, but only once
                      that.sessionKey = null;
                      that.login(function(err, success) {
                          // If we've already aborted the request,
                          // just do nothing
                          if (req.wasAborted) {
                              return;
                          }
  
                          if (err) {
                              // If there was an error logging in, send it through
                              callback(err);
                          }
                          else {
                              // Relogging in was successful, so we execute
                              // our task again.
                              task(callback);
                          }
                      });
                  }
                  else {
                      callback.apply(null, arguments);
                  }
              };
  
              if (!this._shouldAutoLogin() || this.sessionKey) {
                  // Since we are not auto-logging in, just execute our task,
                  // but intercept any 401s so we can login then
                  req = task(reloginIfNecessary);
                  return req;
              }
  
              // OK, so we know that we should try and autologin,
              // so we try and login, and if we succeed, execute
              // the original task
              req = this.login(function(err, success) {
                  // If we've already aborted the request,
                  // just do nothing
                  if (req.wasAborted) {
                      return;
                  }
  
                  if (err) {
                      // If there was an error logging in, send it through
                      callback(err);
                  }
                  else {
                      // Logging in was successful, so we execute
                      // our task.
                      task(callback);
                  }
              });
  
              return req;
          }