def send(self, **req_kwargs):
        """Send an authenticated request to a Google API.
        Automatically retries if the access token has expired.

        Args:
            **req_kwargs: Arbitrary keyword arguments to pass to Requests.

        Return:
            dict: The parsed JSON response.

        Raises:
            APIException: If the server returns an error.
            LoginException: If :py:meth:`login` has not been called.
        """
        i = 0
        while True:
            response = self._send(**req_kwargs).json()
            if 'error' not in response:
                break

            error = response['error']
            if error['code'] != 401:
                raise exception.APIException(error['code'], error)

            if i >= self.RETRY_CNT:
                raise exception.APIException(error['code'], error)

            logger.info('Refreshing access token')
            self._auth.refresh()
            i += 1

        return response
def send ( self , ** req_kwargs ) : i = 0 while True : response = self . _send ( ** req_kwargs ) . json ( ) if 'error' not in response : break error = response [ 'error' ] if error [ 'code' ] != 401 : raise exception . APIException ( error [ 'code' ] , error ) if i >= self . RETRY_CNT : raise exception . APIException ( error [ 'code' ] , error ) logger . info ( 'Refreshing access token' ) self . _auth . refresh ( ) i += 1 return response
Send an authenticated request to a Google API.
        Automatically retries if the access token has expired.

        Args:
            **req_kwargs: Arbitrary keyword arguments to pass to Requests.

        Return:
            dict: The parsed JSON response.

        Raises:
            APIException: If the server returns an error.
            LoginException: If :py:meth:`login` has not been called.