fitbit | Analyzes heart rate and sleep cycles from the fitbit api | Time Series Database library
kandi X-RAY | fitbit Summary
kandi X-RAY | fitbit Summary
The Fitbit API was the major challenge to this project. I could not find a suitable Oauth2 gem or a suitable gem to hook into the Fitbit API. As a result, I ended up building my own client gem linked above. I did not want it attached to the project for both reusability and testing purposes. It ended up being a good exercise. The project is very simply in layout. I have a home controller, a user controller and a controller to handle the Oauth callbacks. The user simply signs in with Fitbit, where I use the ID they send to create a user in the database. It is basically a one page app, the user signs in and is then directed to the users controller, where they can select a date to view their sleep patterns. The difficulty in this project came down to analyzing the data in a quick and efficient manner. The App gets your sleep data from Fitbit which includes high level information from the accelerometer, giving you a basic idea of how restless you were. It then gets makes a call to the heart rate endpoint based on the length of your sleep and gets the second level heart rate data. Finally, it takes these two separate JSON strings, and builds them into one two dimensional array, including the sleep stages (my own algorithm), moving averages, overall average, volatility and resting heart rate. To get all the data I need to build a chart like in the picture above, I need to make at least three different API calls, sometimes four depending on the date. One of the trickier parts was figuring out the date of the sleep, and getting the exact series for the heart rate that was needed, since the measurements for the accelerometer and the heart rate come in different series, this meant I had to develop a data structure to quickly search through heart rate data and find the corresponding time for the accelerometer, and then place both of those in the same, new, data structure. Everything is saved to a big Postgres array. It takes around 100ms to actually save the data, but once it is saved there is no reason to need to modify the data unless the algorithm changes.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Default prefetch handler .
- Handle the response
- Searches for a given selector .
- Create animation animation .
- Creates a new matcher .
- Main matcher function
- workaround for AJAX requests
- Remove data from an element .
- Gets an internal data cache .
- Compute style tests
fitbit Key Features
fitbit Examples and Code Snippets
Community Discussions
Trending Discussions on fitbit
QUESTION
I've been trying to connect an Android App to the Fitbit API using Retrofit however I'm struggling with getting a connection to a JSON with a nested user section. I've managed to get the classes set up however get Body: com.example.myapplication.User@6fe68c1 when requesting the body back.
Whilst learning about Retrofit I've had no problems with using however this seems to be different because of the "user" in the JSON.
Shortened JSON I'm working from
...ANSWER
Answered 2022-Mar-27 at 00:02Solution:
Change Call()
to Call()
and response.body().getUser().toString()
If you want textViewResult.setText("Body: " + response.body());
to give you string representation of your User data you have to override toString()
function on your User object. For example:
QUESTION
Found below script online for syncing Fitbit data with Google Sheets using apps script.
...ANSWER
Answered 2022-Feb-21 at 09:10Too many parameters here as prompt
is only expecting three parameters: title
, prompt
and buttons
:
QUESTION
I am trying to develop an app for Fitbit Versa 3. I am able to connect from my VS code to Fitbit OS simulator, but when I try to install the app using the following two commands:
...ANSWER
Answered 2022-Feb-14 at 01:59It is a simulation problem, I believe. You have to delete the cacert.pem in the simulator, and replace with a new and updated version of cacert.pem in the simulator folder for Versa 3 . Click on this forum discussion to find the cacert.pem download and instructions. The simulator has been broken for a while as announced in November on the Fitbit Development Twitter.
QUESTION
I am developing an Sports Mobile App with flutter (mobile client) that tracks it's users activity data. After tracking an activity (swimming, running, walking ...) it calls a REST API developed by me (with springboot) passing that activity data with a POST. Then, my user will be able to view the logs of his tracked activities calling the REST API with a GET.
As I know that my own tracking development isn't as good as Strava, Garmin, Huawei and so on ones, I want to let my app users to connect with their Strava, Garmin and so on accounts to get their activities data, so I need users to authorize my app to get that data using OAuth.
In a first approach, I have managed to develop all the flow of OAuth with flutter using the Authorization Code Grant. The authorization server login is launched by flutter in a user agent (chrome tab), and once the resource owner has done the login and authorize my flutter app, my flutter app takes the authorization code and the calls to the authorization server to get the tokens . So I can say, that my client is my flutter App. When the oauth flow is done, I send the tokens to my Rest API in order to store them in a database.
My first idea was to send those tokens to my backend app in order to store them in a database and develop a process that takes those tokens, consult resource servers, parses each resource server json response actifvities to my rest API activity model ones and store in my database. Then, if a resource owner consults its activities calling my Rest API, he would get a response with all the activities (the mobiles app tracked ones + Strava, Garmin, resource servers etc ones stores in my db).
I have discarded the option to do the call to the resource servers directly from my client and to my rest api when a user pushes a syncronize button and mapping those responses directly in my client because I need the data of those resource servers responses in the backend in order to implement a medal functionality. Further more, Strava, Garmin, etc have limits of usage and I don't want to let my resource owners the hability to push the button the times they want.
Here is the flow of my first idea:
Steps:
Client calls the authorization server launching a user agent to an oauth login. In order to make the resource owner login and authorize. The url and the params are hardcoded are hardcoded in my client.
Resource owner logins and authorize client.
Callback is sent with code.
Client captures code of the callback and makes a post to he authorization server to get the tokens. As some authorization servers accept PKCE, I am using PKCE when its possible, to avoid attacks and hardcoding my client secret in my client. Others like Strava's, don't allow PKCE, so I have to hardcode the client secret in my client in order to get the tokens.
Once the tokens are returned to my client, I send them to my rest api and store in a database identifying the tokens resource owner.
To call the resource server:
One periodic process takes the tokens of each resource owner and updates my database with the activities returned from each resource server.
The resource owner calls the rest api and obtains all the activities.
The problem to this first idea is that some of the authorization servers allow implementing PKCE (Fitbit) and others use the client secret to create the tokens (Strava). As I need the client secret to get the tokens for some of those authorization servers, I have hardcoded the secrets in the client and that is not secure.
I know that it is dangerous to insert the client secrets into the client as a hacker can decompile my client and get the client secret. I can't figure how to get the resource owner tokens of Strava without hardcoding the client secret if PKCE is not allowed in the authorization server.
As I don't want to hardcode my client secrets in my client because it is insafe and I want to store the tokens in my db, I dont see my first approach as a good option. Further more, I am creating a POST request to my REST API in order to store the access token and refresh token in my database and if i am not wrong, that process can be done directly from the backend.
I am in the situation that I have developed a public client (mobile app) that has hardcoded the client secrets because I can't figure how to avoid doing that when PKCE isn't allowed by the authorization server to get the tokens.
So after thinking on all those problems, my second idea is to take advantage of my REST API and do the call to the authorization server from there. So my client would be confidential and I would do the OAuth flow with a Server-side Application.
My idea is based on this image.
In order to avoid the client secret hardcoding in my mobile client, could the following code flow based on the image work and be safe to connect to Strava, Garmin, Polar....?
Strava connection example:
MOBILE CLIENT
Mobile public Client Calls my Rest API to get as a result the URI of Strava Authorization server login with needed params such as: callback, redirect_uri, client_it, etc.
Mobile client Catches the Rest API GET response URI.
Mobile client launches a user agent (Chrome custom tab) and listen to the callback.
USER AGENT
The login prompt to strava is shown to the resource owner.
The resource owner inserts credentials and pushes authorize.
Callback is launched
MOBILE CLIENT
When my client detects the callback, return to client and stract the code from the callback uri.
Send that code to my REST API with a post. (https://myrestapi with the code in the body)
REST API CLIENT
Now, the client is my REST API, as it is going to be the one that calls the authorization server with the code obtained by the mobile client. The client will take that code and with the client secret hardcoded in it will call to the Authorization server. With this approach, the client secret is no more in the mobile client, so it is confidential.
The authorization server returns the tokens and I store them in a database.
THE PROCESS
- Takes those tokens from my database and make calls to the resource servers of strava to get the activities. Then parses those activities to my model and stores them into the database.
Is this second approach a good way to handle the client secrets in order to avoid making them public? Or I am doing something wrong? Whatr flow could I follow to do it in the right way? I am really stuck with this case, and as I am new to OAuth world I am overwhelmed with all the information I have read.
...ANSWER
Answered 2022-Jan-25 at 12:54From what I understand, the main concern here is, you want to avoid hardcoding of client secret.
I am taking keycloak as an example for the authorization server, but this would be same in other authorization server as well since the implementation have to follow the standards
In the authrization servers there are two types of client's one is the
1.Confidential client - These are the one's that require both client-id and client-secret to be passed in your Rest api call
The CURL would be like this, client secret required
QUESTION
I'm trying to read this json string players.Metadata:
...ANSWER
Answered 2022-Jan-01 at 16:54Because fitbit is an empty array. It is not a string.
QUESTION
I need to select the first image I see (up the DOM) after the link. I have such a code, but for some reason it does not work, where can there be an error?
...ANSWER
Answered 2021-Nov-15 at 22:35Put an @ in front of the href in your xpath statement and it should work given that the element before the link is an image.
QUESTION
Currently, I am working/integrating Fitbit API on my Yii2 framework.
Code sample like this:
...ANSWER
Answered 2021-Sep-06 at 04:29You can use URL 'https://api.fitbit.com/oauth2/revoke' and your existing access_token for refresh or regenerate.
QUESTION
I'm trying to bulk import a JSON file with exercise data from Fitbit. Before I insert the data into a table, I want to find all the distinct key names used across the entire file.
TL;DR: How do I "collapse" the OUTER APPLY
results below into a single set of distinct keys?
ANSWER
Answered 2021-Sep-02 at 17:05You can use the DISTINCT keyword to condense the results:
QUESTION
I've been trying to compare the user's input to values in a dictionary provided.
Question:
Your program should ask how much money you have to spend. Then, it should use the dictionary we've provided with the items and their prices to figure out which ones you have enough money for.
Code
...ANSWER
Answered 2021-Aug-18 at 04:51This should work
QUESTION
The goal is to get the device.lastSyncTime from the companion index.js
to the app/index.js
in a Fitbit Sense clockface (SDK 6.0.0).
My simple idea was that the tellSync()
function would send a message containing the device.lastSyncTime
ANSWER
Answered 2021-Aug-10 at 19:03It was an issue of a data type. A modification of the tellSync() function fixed it:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fitbit
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page