FitBit Worker - Sage-Bionetworks/BridgeWorkerPlatform GitHub Wiki
This guide assumes you are familiar with Bridge and Synapse, and that you have already followed or are concurrently following the BridgeWorkerPlatform Getting Started guide.
This guide also assumes you're familiar with FitBit's Web API and that you know how to set up and authenticate against the FitBit Web API.
Configuring Bridge for Fitbit
-
If you haven't already created and configured a Synapse project for your Bridge study, do so now. The instructions can be found in the Bridge Exporter Testing Guide, sections "Create a Synapse Project" and "Configure your Bridge Study".
-
In addition, the Bridge study's JSON must also contain the following:
"oAuthProviders":{ "fitbit":{ "clientId":"[clientId]", "secret":"[clientSecret]", "endpoint":"https://api.fitbit.com/oauth2/token", "callbackUrl":"[callbackUrl]" } }
Note: If you made a previous update to the study in step 1 to add the Synapse project ID and team ID, you'll need to GET the study from Bridge Server again and copy-paste that JSON. Otherwise, Bridge will throw a 409 ConcurrentModificationException.
-
Authenticate with your FitBit account and get an auth code. (Note: We use the Authorization Code Grant flow, not the Implicit Grant flow. Make sure this is an auth code and not an auth token.) The FitBit Worker currently expects the activity and heartrate scopes.
-
Sign in to Bridge with a consented user, then make the the following request to
POST /v3/oauth/fitbit
:{ "authToken":"[auth code]" }
Your study is now set up to export FitBit data from your FitBit account.
Testing the FitBit Worker
-
Ensure the Bridge Server (and its dependencies such as Redis and MySQL) and the Worker Platform are both running.
-
In the AWS console, go to Simple Queue Service (SQS), select the queue your Worker Platform reads from, and send the following message:
{ "service":"FitBitWorker", "body":{ "date":"2018-01-15", "studyWhitelist":["api"] } }
where "date" is the date you want to export data from.
The studyWhitelist is optional, but specifying it allows you to target just the study you want to export rather than exporting all studies in your local Bridge env. This is useful if you have a lot of studies.