I have a unique constraint to connect to google analytics from app engine - retrieve the data do the calculations and change the data in website.
Everything has to be done automatically and no manual interactions. But there is a problem with google authentication.
I followed various tutorials to connect to GA from app engine but it seems authentication is the big problem.
eg: Followed the below tutorial and when i run the code in my local , it will open browser to authenticate and able to successfully retrieve the result. https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-py
Also, followed one of the good link http://www.marinamele.com/use-google-analytics-api-with-python but it seems authentication problem when we run in cloud.
Also tried storing credentials in client_secrets.json file and deployed to app engine and it was working for 60 mins, after that access_token expired and not able to reach analytics api and 500 error was thrown.
Any suggestions on how to connect to google analytics from google app engine via a crob job to get the analytics data, do the computation and change the database to show different content in website.