Reputation: 6193
I've a Python script on a server, which runs every day at morning, and syncing rows from several databases to a Google Spreadsheet. This script runs till May of 2016 on that server without any problem, and runs an another one too since older. The scripts are equals and use same JSON credentials files. A few days ago, on that server I've got this error message:
File "/usr/local/lib/python2.7/dist-packages/gspread/client.py", line 326, in authorize
client.login()
File "/usr/local/lib/python2.7/dist-packages/gspread/client.py", line 85, in login
self.auth.refresh(http)
File "/usr/lib/python2.7/dist-packages/oauth2client/client.py", line 516, in refresh
self._refresh(http.request)
File "/usr/lib/python2.7/dist-packages/oauth2client/client.py", line 653, in _refresh
self._do_refresh_request(http_request)
File "/usr/lib/python2.7/dist-packages/oauth2client/client.py", line 710, in _do_refresh_request
raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: invalid_grant
But (as I wrote) the same script runs without problem on another server. The two scripts uses different spreadsheets, but all of them had permissions for the service user. There isn't any changes in documents shared, permissions, etc. Both server has same script and json credential file, but the mentioned server asserts this message. That scripts had worked about 3 months. No changes in code, nor permissions.
What would be the problem?
Thanks, a.
Upvotes: 0
Views: 605
Reputation: 636
Your issue was most probably caused due to a wrong server time synchronizaton.
Next time, try to sync your server time to Network Time Servers by, for example, installing ntp.
That should solve the issue.
Upvotes: 1