Search code examples
restgoogle-fit

Some users have no data sources but have data in Google Fit app


My team has published an app that retrieves users' Google Fit data using the REST API to display how active they are and grade their fitness level. I'm interested in the steps and active_minutes metrics.

About 50% of our users have either no data sources or limited data sources. Some of these users are on my team and I have verified they have accepted the required scopes and that the Fit app is indeed recording data.

To test users, I am refreshing their access token (which works fine) and then calling this endpoint to retrieve a list of available data sources: GET fitness/v1/users/me/dataSources (https://developers.google.com/fit/rest/v1/reference/users/dataSources/list)

Sometimes the datasources will be an empty array, and sometimes it will have a very limited number of data sources (ex. data sources involving calories, but not steps, even though steps are showing up just fine in Fit).

I am requesting the following scopes: fitness.activity.read fitness.body.write

The other 50% of our users work just fine and I am completely stumped at what is different about the users that appear to have no (or limited) data sources.


Solution

  • I found that some users had syncing disabled for Google Fit. To enable syncing you must go into the Settings app of your Android phone:

    Settings -> Accounts -> Select your Google account being used for Google Fit -> Ensure that Google Fit is enabled for syncing.

    This answers the most puzzling case where we had users with some data sources, but not all of the expected data sources such as estimated steps. I presume the limited data sources available were from a short time period before syncing was disabled, or while the user was using an outdated version of Google Fit. I'm also finding users with more obvious problems, like using OAuth with a Google account different than the one connected to Google Fit.