On this page:
4.1 Fitbit client
4.2 Livongo client
8.12

4 Example Command Line Tools🔗ℹ

The following are tools to access commonly-used services that are OAuth 2.0 protected. They show how the client flows are used in a real application as well as providing a framework for tools to use.

All tools need to determine their authorization state, which can be one of:

  1. no client - either no client stored for the service, or the client has no id and secret stored.

  2. no token - the client is fully configured but has not been used to fetch an authoriztion token.

  3. authorized - both the client and token are present in the persistent storage.

If the tools detect either of the first two states the tool will not perform any protected calls, but force authorization. For services using code grant, the use of the -i and -s flags are required. For services using password grant the use of the -u and -p flags are required.

  $ fitbit -i HDGGEX -s SGVsbG8gV29ybGQgZnJvbSBTaW1vbgo=

Fitbit returned authenication token: I2xhbmcgcmFja2V0L2Jhc2UKOzsKOzsg\

c2ltcGxlLW9hdXRoMiAtIHNpbXBsZS1vYXV0aDIuCjs7ICAgU2ltcGxlIE9BdXRoMiBjb\

GllbnQgYW5kIHNlcnZ

All of the tools share two output formatting arguments; firstly specifying an output format (using -f which defaults to CSV) and output file to write to (using -o).

4.1 Fitbit client🔗ℹ

This tool implements simple queries against the Fitbit API. Once the client has been authorized and the token stored, the tool will perform queries against the sleep and weight scope. Queries support a common set of arguments to specify either a single data (using -s, which defaults to the current data) or a data range (using -s and -e).

  $ fitbit -h

fitbit [ <option> ... ] <scope>

 where <option> is one of

/ -v, --verbose : Compile with verbose messages

\ -V, --very-verbose : Compile with very verbose messages

  -s <start>, --start-date <start> : Start date (YYYY-MM-DD)

  -e <end>, --end-date <end> : End date (YYYY-MM-DD)

  -u <units>, --units <units> : Unit system (US, UK, metric)

  -f <format>, --format <format> : Output format (csv)

  -o <path>, --output-file <path> : Output file

  --help, -h : Show this help

The following example retrieves the sleep record for a data range as CSV.

  $ fitbit -s 2018-07-16 -e 2018-07-21 sleep

date,start,minbefore,minasleep,minawake,minafter,efficiency,deep:min,\

deep:avg,deep:count,light:min,light:avg,light:count,rem:min,rem:avg, \

rem:count,wake:min,wake:avg,wake:count

2018-07-17,2018-07-16T23:42:00.000,0,494,40,1,97,122,0,6,197,0,21,175\

,0,6,40,0,20

The following retrieves the current dates weight record formatted as an on-screen table.

  $ fitbit -f screen weight

┌───────────┬──────────┬────────┬───────┬──────────────────┐

│date       │ time     │ weight │ bmi   │ fat              

├───────────┼──────────┼────────┼───────┼──────────────────┤

│2019-02-05 │ 15:04:16 │ 262.2  │ 35.59 │ 39.25299835205078│

└───────────┴──────────┴────────┴───────┴──────────────────┘

4.2 Livongo client🔗ℹ

This tool implements simple queries against the blood glucose readings scope provided by Livongo.

  $ livongo -h

livongo [ <option> ... ] <scope>

 where <option> is one of

/ -v, --verbose : Compile with verbose messages

\ -V, --very-verbose : Compile with very verbose messages

  -s <start>, --start-date <start> : Start date (YYYY-MM-DD), may include time (THH:MM:SS)

  -e <end>, --end-date <end> : End date (YYYY-MM-DD), may include time (THH:MM:SS)

  -f <format>, --format <format> : Output format (csv)

  -o <path>, --output-file <path> : Output file

  --help, -h : Show this help