Reputation: 93
When I upload or download a large file and it lasts more than one hour, the upload/download interrupts with the following error message after exactly one hour:
Google.GoogleApiException: Google.Apis.Requests.RequestError
Invalid Credentials [401]
Errors [
Message[Invalid Credentials] Location[Authorization - header] Reason[authError] Domain[global]
]
There is no difference whether I run this with Web Authorization or Service Account Authorization.
I am not sure if it relates to the AuthToken expiration, because if I upload smaller files, then I am able to upload many files, and there is no interruption after an hours. For small files, everything runs smoothly and works for a very long time.
It looks like a similar issue is described here, but that question has not been answered.
My code is as following:
DriveService service;
// ....
FilesResource.InsertMediaUpload request = service.Files.Insert(body, stream, mimeType);
request.Upload();
Upvotes: 2
Views: 1185
Reputation: 69
This is the real issue where it's being tracked: Issue 5700 of GData API.
As of April 30, the answer from a Google engineer is:
Thanks for everyone's patience—I'm told that the underlying issue should now be fixed in production. As long as the OAuth 2 access token is valid at the start of the upload, the upload should complete successfully. An access token that expires in the middle of an upload will no longer cause an HTTP 401 response.
Please let us know if you're still seeing any issues. I'll leave this bug open until I can confirm from your feedback that it's resolved in your applications.
Apparently problems still exist, so if you're having problems with this please comment on Issue 5700.
Upvotes: 1
Reputation: 8183
The problem is on the Google Drive endpoint and can't be fixed in your code.
Some guy filed an issue about this at Jan 13, 2013, and more than one year has passed, it seems no updates from Google about this, and others still meet this problem.
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.
And here's another report about this issue.
Upvotes: 2