code: def _request(self, uri, method='GET', params=None, files=None, headers=None, auth=None):
          
          if headers:
              headers['Accept'] = 'application/json'
          else:
              headers = {
                  'Accept': 'application/json',
              }
  
          if not self.api_token:
              # need to log in
              response = sandboxapi.SandboxAPI._request(self, '/auth/login', 'POST', headers=headers,
                                                        auth=HTTPBasicAuth(self.username, self.password))
              if response.status_code != 200:
                  raise sandboxapi.SandboxError("Can't log in, HTTP Error {e}".format(e=response.status_code))
              # we are now logged in, save the token
              self.api_token = response.headers.get('X-FeApi-Token')
  
          headers['X-FeApi-Token'] = self.api_token
  
          response = sandboxapi.SandboxAPI._request(self, uri, method, params, files, headers)
  
          # handle session timeout
          unauthorized = False
          try:
              if json.loads(response.content.decode('utf-8'))['fireeyeapis']['httpStatus'] == 401:
                  unauthorized = True
          except (ValueError, KeyError, TypeError):
              # non-JSON response, or no such keys.
              pass
  
          if response.status_code == 401 or unauthorized:
              self.api_token = None
              try:
                  headers.pop('X-FeApi-Token')
              except KeyError:
                  pass
  
              # recurse
              return self._request(uri, method, params, files, headers)
  
          return response
docs: Override the parent _request method.
  
          We have to do this here because FireEye requires some extra
          authentication steps. On each request we pass the auth headers, and
          if the session has expired, we automatically reauthenticate.