'Google fit API script needs constant authorisation when trying to run automatically & how to extract additional info

I have a script that exports data from the Google Fit API to Google Spreadsheets. The script was found here - https://ithoughthecamewithyou.com/post/export-google-fit-daily-steps-to-a-google-sheet and works.

When I run the script daily manually, it works. However, when I have it set up to run automatically and scrape the data each morning, I get an email saying that it failed to run as authorisation was required.

I'm sure it's something simple, but how can I have it set up so that authorisation isn't required?

Additionally, the ultimate goal is to build some form of dashboard from the data stored on that spreadsheet. Is it possible to scrape additional information, such as what the exercise was? I know that info is stored there, but I'm just not sure how to access it.

For example, I'd like to scrape the data that has been identified as a run on Google Fit.



Solution 1:[1]

Google fit Access OAuth token are process short-lived, and they do not last for long period. So you will be required to identify yourself with credentials on every instance request or after 60 mins per documentation for security reasons.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ilovesyntax