FLOW.params['access_type'] = 'offline'
.credentials_json = credentials.to_json()
. It contains a refresh_token
.Credentials.new_from_json(credentials_json)
.credentials.authorize(http)
.Credentials
class refresh it's token automatically?credentials.refresh(http)
?Thanks!
Your refresh token is used to get a new access token every time that the access token expires.
Here google says that the access token is automatically refreshed using the refresh token when it expires.
In our application, we call credentials.refresh(http)
when the token is near to expiry
if (credentials.token_expiry - datetime.utcnow()) < timedelta(minutes=refresh_mins):
credentials.refresh(httplib2.Http())
refresh_mins
has a default value of 15 in our code base. This is because the access token expires in 60 minutes. We refresh every 45 mins. More details about this can be found here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With