private async Task <responseModel> autoAuthorize <responseModel>(SheetsBaseServiceRequest <responseModel> reqes)
        {
            bool hasRetried = false;

            while (true)
            {
                try
                {
                    reqes.AccessToken = _accessToken;
                    return(await reqes.ExecuteAsync());
                }
                catch (Exception e)
                {
                    if (!hasRetried && isUnauthorize(e))
                    {
                        await authorize();

                        hasRetried = true;
                    }
                    else
                    {
                        throw e;
                    }
                }
            }
        }
Example #2
0
        public async Task <TResponse> Execute <TResponse>(SheetsBaseServiceRequest <TResponse> request)
        {
            await Task.Delay(1000);

            for (var attempt = 1; attempt <= 5; attempt++)
            {
                try
                {
                    return(await request.ExecuteAsync());
                }
                catch when(attempt < 5)
                {
                    await Task.Delay(2000 *attempt);
                }
            }
            return(default);