I'm trying to use the gdata.spreadsheets.client
and OAuth2TokenFromCredentials
to process a google spreadsheet.
After 1 hour I receive a 401 error(unauthorized) due to access token expiration any way automatically refreshing the access token, though it's changing the new access token the process is frequently getting HTTP 401 error (unauthorized).
After reaching same error 10 times the process quits, so the file is not processed completely.
Sample code where we receive the 401 error:
def write_row(self, row, data_row):
# Attempt to write new row and skip if writing row causes error.
try:
gdoc_util.update_row_retryable(self.spr_client, row, data_row, force=True)
except Exception as e:
logging.exception(e)
self.writing_error_count += 1
if self.writing_error_count > self.MAX_ERROR_COUNT:
print 'Max error limit reached, ending scraper...'
quit()
I am running this process with multiprocessing.
Why with new access tokens is not working like as before, but frequently receiving 401 error(unauthorized)?
Same error like here: Google Drive Python API resumable upload error 401 after 2 hours