What I’m trying to do: I have an app that writes to a Google Sheet. It runs fine, but every couple of hours I receive this error and have to restart the app.
anvil.server.InternalError: Google request failed: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
at /home/anvil/downlink/anvil/_threaded_server.py, line 482
called from /home/anvil/downlink/anvil/server.py, line 68
called from /home/anvil/downlink/anvil/google/drive.py, line 610
called from ServerModule1, line 42
called from /home/anvil/downlink/anvil/_threaded_server.py, line 169
called from HomeForm, line 105
What I’ve tried and what’s not working: I haven’t tried anything yet. The sheet has been added using App Files. Below is what is called every time a row is added
Code Sample:
db = app_files.gsheet
ws = db['responses']
if wt:
ws.add_row(
datetime=now_str,
truck=tk,
gross=wt,
tare=tare,
net=int(wt) - tare,
tons = (int(wt) - tare) / 2000,
metric_tons = round((int(wt) - tare) / 2204.1, 2),
shift=shift)
else:
ws.add_row(datetime=now_str, truck=tk, shift=shift)