Refresh Access Token
Learn to generate a refreshed access token with a new expiry.
We'll cover the following
Generate refreshed API keys
Click the "Run" button in the widget below to refresh the ACCESS_TOKEN
.
Note: Make sure the values for the
CLIENT_ID
,CLIENT_SECRET
,ACCESS_TOKEN
,REFRESH_TOKEN
, andEXPIRY
are already set.
main.py
token.json
from google.oauth2.credentials import Credentialstry:credentials = Credentials.from_authorized_user_file('token.json')refresh_token(credentials)except:print("Please enter your access token data in the token.json file")
The above code generates a new value for the ACCESS_TOKEN
with a new EXPIRY
. These two values along with the REFRESH_TOKEN
are displayed and extracted from the output to be saved as API keys.
Click the "Save" button to save the keys.