

def authorize(self, client):
    "Authorize a gdata.client.GDClient instance with these credentials.\n\n    Args:\n       client: An instance of gdata.client.GDClient\n           or something that acts like it.\n\n    Returns:\n       A modified instance of client that was passed in.\n\n    Example:\n      >>> c = gdata.client.GDClient(source='user-agent')\n      >>> c = token.authorize(c)\n    "
    client.auth_token = self
    request_orig = client.http_client.request

    def new_request(http_request):
        response = request_orig(http_request)
        if (response.status == 401):
            refresh_response = self._refresh(request_orig)
            if self._invalid:
                return refresh_response
            else:
                self.modify_request(http_request)
                return request_orig(http_request)
        else:
            return response
    client.http_client.request = new_request
    return client

dataset/ETHPy150Open acil-bwh/SlicerCIP/Scripted/attic/PicasaSnap/gdata/gauth.py OAuth2Token.authorize/original