Script python API Google FIT

Job ID: 32454760

Budget: $10 – $30 USD

I'm trying to develop a python script to get the health data from the Google Fit API. I was even able to query some data, but I run into the problem that the token expires in 60 minutes, and I don't know how to generate a token automatically. So, I want a script in python that generates a token whenever the previous token expires. In the attached file is my attempt.
Related categories: Python Web Scraping API Web API Google APIs