(
        self,
        method,
        url,
        data=None,
        headers=None,
        max_allowed_time=None,
        timeout=_DEFAULT_TIMEOUT,
        auto_decompress=False,
        **kwargs,
    )
return response
Implementation of Authorized Session aiohttp request.

        Args:
            method (str):
                The http request method used (e.g. GET, PUT, DELETE)
            url (str):
                The url at which the http request is sent.
            data (Optional[dict]): Dictionary, list of tuples, bytes, or file-like
                object to send in the body of the Request.
            headers (Optional[dict]): Dictionary of HTTP Headers to send with the
                Request.
            timeout (Optional[Union[float, aiohttp.ClientTimeout]]):
                The amount of time in seconds to wait for the server response
                with each individual request. Can also be passed as an
                ``aiohttp.ClientTimeout`` object.
            max_allowed_time (Optional[float]):
                If the method runs longer than this, a ``Timeout`` exception is
                automatically raised. Unlike the ``timeout`` parameter, this
                value applies to the total method execution time, even if
                multiple requests are made under the hood.

                Mind that it is not guaranteed that the timeout error is raised
                at ``max_allowed_time``. It might take longer, for example, if
                an underlying request takes a lot of time, but the request
                itself does not timeout, e.g. if a large file is being
                transmitted. The timout error will be raised after such
                request completes.
Implementation of Authorized Session aiohttp request.
Implementation of Authorized Session aiohttp request .
async def request(
        self,
        method,
        url,
        data=None,
        headers=None,
        max_allowed_time=None,
        timeout=_DEFAULT_TIMEOUT,
        auto_decompress=False,
        **kwargs,
    ):

        """Implementation of Authorized Session aiohttp request.

        Args:
            method (str):
                The http request method used (e.g. GET, PUT, DELETE)
            url (str):
                The url at which the http request is sent.
            data (Optional[dict]): Dictionary, list of tuples, bytes, or file-like
                object to send in the body of the Request.
            headers (Optional[dict]): Dictionary of HTTP Headers to send with the
                Request.
            timeout (Optional[Union[float, aiohttp.ClientTimeout]]):
                The amount of time in seconds to wait for the server response
                with each individual request. Can also be passed as an
                ``aiohttp.ClientTimeout`` object.
            max_allowed_time (Optional[float]):
                If the method runs longer than this, a ``Timeout`` exception is
                automatically raised. Unlike the ``timeout`` parameter, this
                value applies to the total method execution time, even if
                multiple requests are made under the hood.

                Mind that it is not guaranteed that the timeout error is raised
                at ``max_allowed_time``. It might take longer, for example, if
                an underlying request takes a lot of time, but the request
                itself does not timeout, e.g. if a large file is being
                transmitted. The timout error will be raised after such
                request completes.
        """
        # Headers come in as bytes which isn't expected behavior, the resumable
        # media libraries in some cases expect a str type for the header values,
        # but sometimes the operations return these in bytes types.
        if headers:
            for key in headers.keys():
                if type(headers[key]) is bytes:
                    headers[key] = headers[key].decode("utf-8")

        async with aiohttp.ClientSession(
            auto_decompress=self._auto_decompress
        ) as self._auth_request_session:
            auth_request = Request(self._auth_request_session)
            self._auth_request = auth_request

            # 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 {}

            # Do not apply the timeout unconditionally in order to not override the
            # _auth_request's default timeout.
            auth_request = (
                self._auth_request
                if timeout is None
                else functools.partial(self._auth_request, timeout=timeout)
            )

            remaining_time = max_allowed_time

            with requests.TimeoutGuard(remaining_time, asyncio.TimeoutError) as guard:
                await self.credentials.before_request(
                    auth_request, method, url, request_headers
                )

            with requests.TimeoutGuard(remaining_time, asyncio.TimeoutError) as guard:
                response = await super(AuthorizedSession, self).request(
                    method,
                    url,
                    data=data,
                    headers=request_headers,
                    timeout=timeout,
                    **kwargs,
                )

            remaining_time = guard.remaining_timeout

            if (
                response.status in self._refresh_status_codes
                and _credential_refresh_attempt < self._max_refresh_attempts
            ):

                requests._LOGGER.info(
                    "Refreshing credentials due to a %s response. Attempt %s/%s.",
                    response.status,
                    _credential_refresh_attempt + 1,
                    self._max_refresh_attempts,
                )

                # Do not apply the timeout unconditionally in order to not override the
                # _auth_request's default timeout.
                auth_request = (
                    self._auth_request
                    if timeout is None
                    else functools.partial(self._auth_request, timeout=timeout)
                )

                with requests.TimeoutGuard(
                    remaining_time, asyncio.TimeoutError
                ) as guard:
                    async with self._refresh_lock:
                        await self._loop.run_in_executor(
                            None, self.credentials.refresh, auth_request
                        )

                remaining_time = guard.remaining_timeout

                return await self.request(
                    method,
                    url,
                    data=data,
                    headers=headers,
                    max_allowed_time=remaining_time,
                    timeout=timeout,
                    _credential_refresh_attempt=_credential_refresh_attempt + 1,
                    **kwargs,
                )

        return response
async def request ( self , method , url , data = None , headers = None , max_allowed_time = None , timeout = _DEFAULT_TIMEOUT , auto_decompress = False , * * kwargs , ) : # Headers come in as bytes which isn't expected behavior, the resumable # media libraries in some cases expect a str type for the header values, # but sometimes the operations return these in bytes types. if headers : for key in headers . keys ( ) : if type ( headers [ key ] ) is bytes : headers [ key ] = headers [ key ] . decode ( "utf-8" ) async with aiohttp . ClientSession ( auto_decompress = self . _auto_decompress ) as self . _auth_request_session : auth_request = Request ( self . _auth_request_session ) self . _auth_request = auth_request # 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 { } # Do not apply the timeout unconditionally in order to not override the # _auth_request's default timeout. auth_request = ( self . _auth_request if timeout is None else functools . partial ( self . _auth_request , timeout = timeout ) ) remaining_time = max_allowed_time with requests . TimeoutGuard ( remaining_time , asyncio . TimeoutError ) as guard : await self . credentials . before_request ( auth_request , method , url , request_headers ) with requests . TimeoutGuard ( remaining_time , asyncio . TimeoutError ) as guard : response = await super ( AuthorizedSession , self ) . request ( method , url , data = data , headers = request_headers , timeout = timeout , * * kwargs , ) remaining_time = guard . remaining_timeout if ( response . status in self . _refresh_status_codes and _credential_refresh_attempt < self . _max_refresh_attempts ) : requests . _LOGGER . info ( "Refreshing credentials due to a %s response. Attempt %s/%s." , response . status , _credential_refresh_attempt + 1 , self . _max_refresh_attempts , ) # Do not apply the timeout unconditionally in order to not override the # _auth_request's default timeout. auth_request = ( self . _auth_request if timeout is None else functools . partial ( self . _auth_request , timeout = timeout ) ) with requests . TimeoutGuard ( remaining_time , asyncio . TimeoutError ) as guard : async with self . _refresh_lock : await self . _loop . run_in_executor ( None , self . credentials . refresh , auth_request ) remaining_time = guard . remaining_timeout return await self . request ( method , url , data = data , headers = headers , max_allowed_time = remaining_time , timeout = timeout , _credential_refresh_attempt = _credential_refresh_attempt + 1 , * * kwargs , ) return response