STEPZ @ ZPARTNER with Google Fit Integration

Introduction 

If you follow ZPARTNER, you might have noticed that we have built a SAC Native Application for a Fitness Challenge (https://www.zpartner.eu/stepz-2023-zpartner/) for the company employees. As we still do this challenge on a regular basis, we recently enhanced this by integrating Google Fit data into it.  

The idea was to synchronize your tracked fitness data from your Smart Watch, Fitness Watch or another wearable via Google Fit to SAC. Therefore, we built a small Web Application which handles the Google Authentication and extracts the data regularly. 

Architecture 

As already mentioned, we built a small Web Application. The architecture below shows how we designed the interaction between the different systems. We now have the following setup: 

1. A user synchronizes his for example Smart Watch to Google Fit on his phone 

2. In a separate Web Application the user grants the application access to its Google Fit Data 

3. Within this Web Application the data is retrieved and posted to a Google Cloud Storage 

4. In SAC we have a model which imports the data into a SAC 

Web Application 

The Web Application was built mainly to get the users permission to retrieve the Google Fit Data. This is documented within the Google Fit API (https://developers.google.com/fit/rest/v1/authorization?hl=en). Therefore, we setup our own project within Google and registered our App and created and built a “flow” for OAuth 2.0.  

In the end the Web Application perform the following steps: 

1. Authentication 

2. Mapping the Google User to the SAC User 

3. Transferring the Data to the Google Cloud Storage 

4. Logging Information for managing the Users and processes. 

This Web Application was built with Flask, which is a web development Framework in Python. We are running this Web Application on a VM which is hosted on our internal server, so it is only accessible via VPN connection. Besides this we also needed a valid Domain, which is required from Google Site. Therefore, we also needed additional Tools like NGINX and Unicorn which lead to the following setup on our Virtual Machine: 

The Web Application allows now all our employees to be accessed via VPN connection. The App then looks like this:  

The Google Login functionality is available to all the users, but the grey buttons are password protected and can only be accessed from the Admins.  

The Web Application is running a CRON Job which transfers the retrieved information from Google fit and is posting it to the Google Cloud Storage and from there it is then retrieved via a Scheduling Job from SAC. 

Conclusion 

What we built here showed us that a variety of tools is required to build a small Web Application and host on your local Virtual Machine. However, we learned a lot during this project and we were able to integrate data from a fitness device into our SAC Planning Application.