Backgound
- I got access_token to Google API using the google-api-python-client django_sample.
- To have offline access, I've added
FLOW.params['access_type'] = 'offline'
. - Stored
credentials_json = credentials.to_json()
. It contains arefresh_token
. - Restored the credentials
Credentials.new_from_json(credentials_json)
. - Used this credentials to gain access by
credentials.authorize(http)
. - Worked perfectly =)
The problem
- I did the the same every 5 minutes.
- In each iteration I stored the credentials and printed it.
- After 1 hour and 45 minutes, the "refresh_token" became null.
- At this point the code stopped working =(
My questions
- Does
Credentials
class refresh it's token automatically? - If not, at what point of should I call
credentials.refresh(http)
?
Thanks!