WeiliangXing / google-api-python-client

Automatically exported from code.google.com/p/google-api-python-client
Other
0 stars 0 forks source link

Resumable media upload fails once the access_token expires. #231

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
First of all, I don't really know for sure this is a bug, for I'm too beginner 
with both the API and Python. But I tried several different ways and got the 
same error, so I thought it might really be a bug.

When uploading a large file (one that takes more than 1~2 hours to upload 
completely, if I use resumable upload, after about 1h, the upload is 
interrupted with 401 error from server. After some digging in the API 
documentation and source code, I found out that it automatically refreshs the 
access token using the refresh token when it gets this error. Thing is that, 
although it does change the access token, the server keeps responding with 401, 
no matter how many times the access token is refreshed.

I'm attaching the code I used here and copying the terminal output... the 
output lines for the http.request.credentials.access_token are for debugging 
purposes.

ya29.AHES6ZTo_-0oDqwn3JnU2uCR2bRjpRGP0CSQSMHGr6KvgEE
Uploaded 2.28%
ya29.AHES6ZTo_-0oDqwn3JnU2uCR2bRjpRGP0CSQSMHGr6KvgEE
Uploaded 2.29%
ya29.AHES6ZTo_-0oDqwn3JnU2uCR2bRjpRGP0CSQSMHGr6KvgEE
Uploaded 2.29%
ya29.AHES6ZTo_-0oDqwn3JnU2uCR2bRjpRGP0CSQSMHGr6KvgEE
Uploaded 2.30%
ya29.AHES6ZTo_-0oDqwn3JnU2uCR2bRjpRGP0CSQSMHGr6KvgEE
Error (401)... retrying.
ya29.AHES6ZQqp3_qbWsTk4yVDdHnlwc_7GvPZiFIReDnhIIiHao
Error (401)... retrying.
ya29.AHES6ZSqx90ZOUKqDEP4AAfWCVgXZYT2vJAiLwKDRu87JOs
Error (401)... retrying.
ya29.AHES6ZTp0RZ6U5K5UdDom0gq3XHnyVS-2sVU9hILOrG4o3Y
Error (401)... retrying.
ya29.AHES6ZSR-IOiwJ_p_Dm-OnCanVIVhCZLs7H_pYLMGIap8W0
Error (401)... retrying.
ya29.AHES6ZRnmM-YIZj4S8gvYBgC1M8oYy4Hv5VlcwRqgnZCOCE
Error (401)... retrying.
ya29.AHES6ZSF7Q7C3WQYuPAWrxvqbTRsipaVKhv_TfrD_gef1DE
Error (401)... retrying.
ya29.AHES6ZTsGzwIIprpPhCrqmoS3UkPsRzst5YHqL-zXJmz6Ak
Error (401)... retrying.
ya29.AHES6ZSS_1ZBiQJvZG_7t5uW3alsy1piGe4-u2YDnwycVrI
Error (401)... retrying.
ya29.AHES6ZTLFbBS8mSFWQ9zK8cgbX8RPeLghPxkfiKY54hBB-0
Error (401)... retrying.
ya29.AHES6ZQBeMWY50z6fWXvaCcd5_AJr_AYOuL2aiNKpK-mmyU
Error (401)... retrying.
ya29.AHES6ZTs2mYYSEyOqI_Ms4itKDx36t39Oc5RNZHkV4Dq49c
Retries limit exceeded! Aborting.

My version infos:
Debian Lenny, with kernel 2.6.26-2-686.
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) 
[GCC 4.3.2] on linux2

I don't really know how to find the version of the api client, but I got it 
from pip install about a week ago (both the google-api-python-client and ssl).

Original issue reported on code.google.com by grfro...@gmail.com on 13 Jan 2013 at 5:51

Attachments:

GoogleCodeExporter commented 8 years ago
Apparently, the problem isn't with the api, but with long resumable uploads. I 
tried to upload two small files with the same code, but with 1h between them, 
and the api does renew the access token and successfully uploads the second 
file.

I'm attaching this new script and copying the output:

ya29.AHES6ZRUssiLfuhqCP9Cu7C7LuhRV2rYzPldU27wiMJZWb8
Uploaded 66.89%
ya29.AHES6ZRUssiLfuhqCP9Cu7C7LuhRV2rYzPldU27wiMJZWb8
Upload 1 Complete!
ya29.AHES6ZRUssiLfuhqCP9Cu7C7LuhRV2rYzPldU27wiMJZWb8
Uploaded 57.62%
ya29.AHES6ZQd3o1ciwXpNFImH3CK0-dJAtQba_oeIO9DDbIq154
Upload 2 Complete!

Original comment by grfro...@gmail.com on 13 Jan 2013 at 9:40

Attachments:

GoogleCodeExporter commented 8 years ago
This is an issue with the backend and not with the API or with your code. As 
you deduced, if the upload goes too long the access_token expires and at that 
point the resumable upload can't be continued. There is work on progress to fix 
this issue right now, I will update this bug once the issue is fixed on the 
server side.

Original comment by jcgregorio@google.com on 13 Jan 2013 at 11:00