Small python script for load bulk weight/steps data to a Google Fit account. Original code is here.
To run this script, you will need:
python 2.7
pip
(sudo apt install python-pip)virtualenv
(to get it: pip install virtualenv)
git clone https://github.com/TadWohlrapp/weight-csv-to-gfit.git
cd weight-csv-to-gfit
python -m virtualenv -p /usr/bin/python2.7 venv
source venv/bin/activate
pip install -r requirements.txt
There are two options how to access API - register application to create credentials and API key or use OAuth 2.0 Playground to get Authorization Token.
- Export weight data from Withings
- Place
weight.csv
to the project's main folder
- Go to https://console.developers.google.com/apis/credentials
- Create a new OAuth client ID (Create credentials -> OAuth client ID)
- Set the Redirect URI to the playground: https://developers.google.com/oauthplayground
- Download the client secret json file, place it in this project's main folder and rename it to
client_secret.json
- Go to https://console.developers.google.com/apis/credentials
- Create a new API Key (Create credentials -> API Key)
- Copy the key and save it as
api_key.txt
in the project's main folder
cd weight
python import_weight_to_gfit.py
- Go to https://developers.google.com/oauthplayground/
- In Step 1 Select & Authorize APIs: select https://www.googleapis.com/auth/fitness.body.write under API Fitness 1
- Authorize use of API on own account
- In Step 2. Exchange authorization code for tokens: On left side of the screen click on Exchange authorization code for tokens.
- On right side write down numeric part of
client_id
from the request andaccess_token
from the response
cd weight
python import_weight_to_gfit.py <client_id value> <access_token value>