In this article, I’ll explain how I automated some operations on my Fitbit using Tasker. In particular, my goal was to create a task to enable and disable some of my Fitbit’s alarms on particular conditions.
- Tasker 5.12.22
- some basic development skills to understand Fitbit API
All the information can be found on the official Web API site provided by Fitbit.
Step 1. Configure a new Fitbit application
The first thing to do is to create a new application using the My Apps portal.
After the login, we just need to click Register a new app.
And configure it as follows.
It’s important to pay attention to the Redirect URL because it’ll be used to get the access token and the Default Access Type, the Read & Write option is required to change Fitbit settings or data.
Click the Save button to confirm the creation of our new app. On the following page, you need to copy the ClientId.
Step 2. Understand the Authorization flow
In the Authorization Page, you can read how your app should ask the user for authorization to access their data.
In our scenario, we’ll use the Implicit Grant Flow to receive directly the token. The URL of the authorization page is
The URL parts are:
- https://www.fitbit.com/oauth2/authorize: Fitbit authorization page.
- response_type=token: to receive the token.
- client_id=[your-client-id]: here you have to insert the Client ID you have received after the creation of your app.
- scope=settings: specifies which kind of data we want to access from Tasker. You can read more here.
- expires_in=31536000: how long the token will be valid. 31536000 is a year in seconds.
If you try the link after setting your client id, you’ll be redirected to the Redirect URI you configured in the first step with some information appended:
We are going to use the access_token parameter in our tasks.
Step 3. Get familiar with the API
Now we are almost ready to write our tasks. We first need to understand what API calls we’ll need and how to call them.
You can find them all on the Swagger page.
Try them with Postman
I’ve already created a Postman project to test all of the calls I needed. You can import them with this file.
Before testing them make sure to configure the token you have received in the previous step in the collection authorization settings.
Step 4. Tasker
We can finally start writing some tasks in Tasker. To call the Fitbit API we can use the HTTP Request Action.
Here is a list of what I’ve done.
Check and update the Fitbit token
I created a profile that checks every day the validity of my token. If it’s not valid it sends me a notification with two buttons, one to Authorize the app again, and one to submit the new token received.
Here you can see a brief demo. When I click the first button it asks me to log in with my Fitbit account and to authorize the app. I had done this before, so I was redirected without doing it again.
Select which alarms to toggle
Then, I created a task that performs the call to get all the alarms and asks me which one I want to manage automatically. The AlarmIds are saved in an array variable for future use.
Here you can see a brief demo.
Update selected alarms
Finally, I created a task to update all the previously selected alarms to enable/disable them based on a variable called %Mode.
To update the alarms I had to encode manually the body using the Variable Search Replace action (probably not the best approach). I hardcoded the weekDays and recurring parameters because all my alarms are configured in the same way.