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, and EXPIRY are already set.

Press + to interact
Please provide values for the following:
CLIENT_ID
Not Specified...
CLIENT_SECRET
Not Specified...
ACCESS_TOKEN
Not Specified...
REFRESH_TOKEN
Not Specified...
EXPIRY
Not Specified...
main.py
token.json
from google.oauth2.credentials import Credentials
try:
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.

Loginto save progress

Wrap Up!