I use the google API for a personal project, so I don't have my app verified with google.
I use exactly this code example myself and a token.json file gets generated when logging in. Everything works fine, the access token changes more or less every time I make a request (every 10 min).
After a week, the request fails. Exactly a week after the "expiry" field in the token.json file.
google.auth.exceptions.RefreshError: ('invalid_grant: Token has been expired or revoked.', {'error': 'invalid_grant', 'error_description': 'Token has been expired or revoked.'})
If I understand everything correctly, google should update refresh_token as well, but this did not happen.
I thought this part would handle getting a new refresh token:
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request()) ## HERE ##
else:
Might this be caused by my app not being verified? I did not find any information and hardly none about the behavior of the refresh_token.
