code: def request(self, method, url, data=None, headers=None, **kwargs):
          
          # pylint: disable=arguments-differ
          # Requests has a ton of arguments to request, but only two
          # (method, url) are required. We pass through all of the other
          # arguments to super, so no need to exhaustively list them here.
  
          # Use a kwarg for this instead of an attribute to maintain
          # thread-safety.
          _credential_refresh_attempt = kwargs.pop(
              '_credential_refresh_attempt', 0)
  
          # Make a copy of the headers. They will be modified by the credentials
          # and we want to pass the original headers if we recurse.
          request_headers = headers.copy() if headers is not None else {}
  
          self.credentials.before_request(
              self._auth_request, method, url, request_headers)
  
          response = super(AuthorizedSession, self).request(
              method, url, data=data, headers=request_headers, **kwargs)
  
          # If the response indicated that the credentials needed to be
          # refreshed, then refresh the credentials and re-attempt the
          # request.
          # A stored token may expire between the time it is retrieved and
          # the time the request is made, so we may need to try twice.
          if (response.status_code in self._refresh_status_codes
                  and _credential_refresh_attempt < self._max_refresh_attempts):
  
              _LOGGER.info(
                  'Refreshing credentials due to a %s response. Attempt %s/%s.',
                  response.status_code, _credential_refresh_attempt + 1,
                  self._max_refresh_attempts)
  
              auth_request_with_timeout = functools.partial(
                  self._auth_request, timeout=self._refresh_timeout)
              self.credentials.refresh(auth_request_with_timeout)
  
              # Recurse. Pass in the original headers, not our modified set.
              return self.request(
                  method, url, data=data, headers=headers,
                  _credential_refresh_attempt=_credential_refresh_attempt + 1,
                  **kwargs)
  
          return response
docs: Implementation of Requests' request.