03-30-2022 22:10
03-30-2022 22:10
Found this example, does anyone know what fbTok should contain?
fetch( 'https://api.fitbit.com/1/user/-/activities/goals/daily.json?steps=25000', { method: 'POST', headers: new Headers({ 'Authorization': 'Bearer ' + fbTok, }), mode: 'cors', } ).then(processResponse) .then(function(data){ console.log('Request succeeded with response', data);}) .catch(function(error){ console.log(error.message);});
it was taken as best answer from
Author | ch, passion for improvement.
04-01-2022 10:46
04-01-2022 10:46
Hi @Guy_ ,
The 'fbTok' in this example is referring the user's access_token obtained from authorization.
04-01-2022 11:20
04-01-2022 11:20
@JohnFitbit - thanks, is authorisation needed when the userid is "-"?
and if so do you have a sample code to help do that?
Alternatively is there another way to change the Steps goal via internal Api directly from the watch app without using the web Api ?
Author | ch, passion for improvement.
04-01-2022 12:07
04-01-2022 12:07
@Guy_ Yes, authorization is still needed if you're only pulling data from your Fitbit account. I don't have any sample code myself, but you can check the community resources for sample code. However, if you're just looking for a sample of how to format requests using "-", a request would look like this:
curl -X GET "https://api.fitbit.com/1/user/-/activities/date/2019-01-01.json" \
-H "accept: application/json" \
-H "authorization: Bearer <access_token>"
Regarding your 2nd question, the watch app pulls the goal data from the Fitbit app only, so there isn't a way to update the goal directly from the device. When you update the goal through the Fitbit app or Web API, the watch will need to sync to the app in order to update the new metrics.
04-01-2022 12:26 - edited 04-01-2022 12:30
04-01-2022 12:26 - edited 04-01-2022 12:30
@JohnFitbit- thanks for the additional information. It is clear that the Web Api access is needed.
This will be an app that any user can install and run - looking at https://dev.fitbit.com/apps/new not sure this will get what is needed or is necessary.
Looking at the https://github.com/Fitbit/sdk-oauth app it is still not clear how or where the access_token is obtained to work any time for anyone.
Can you offer some more help, perhaps via PM, in case it is sensitive?
The calling sequence should probably be updated in the first post, as the example, as such?
https://api.fitbit.com/1/user/-/activities/goals/daily.json?type=steps&value=25000
Author | ch, passion for improvement.
05-09-2022 20:03
05-09-2022 20:03
Can anyone help?
Author | ch, passion for improvement.
06-18-2022 07:21
06-22-2022 08:31
06-22-2022 08:31
Regarding your question on obtaining the access token using the SDK, the sample code provided is for the companion application that runs on the phone. You would need the user to go through the Web API consent process to share their data with your companion application. It's possible this is done through the Settings API. See https://dev.fitbit.com/build/reference/settings-api/#oauth-button. After the consent process is complete, you'll have the access token. The folks in the SDK section of the forum can help.
06-22-2022 08:34 - edited 06-22-2022 08:37
06-22-2022 08:34 - edited 06-22-2022 08:37
Yes, this can be done. Your application will need to present your authorization URL somehow. When the user click on it, they will be asked to log into their Fitbit account which is where we get their user id. Once they complete the authorization flow, the application will be provided an access and refresh token specific to that user. The application will need to store each access and refresh token for each user utilizing your application and update the tokens accordingly. When a specific user wants to update their activity goal, you'll pull their current access token from your database, call the create activity goal endpoint using their access token.
06-22-2022 10:02
06-22-2022 10:02
Thank you so much @Gordon-C for taking the time to outline the process.
Unfortunately it is so terribly complex I doubt that any normal user would be able to do it, so it would be impractical to even develop such an app.
Many users struggle to even change the weather temperature units, so this would be outside the scope of most users, let alone the few who might be interested and benefit from such an app.
Would there be any other means that a user could simply update his own goal settings from an app without the need for such complexity?
Author | ch, passion for improvement.
06-23-2022 07:32
06-23-2022 07:32
The users can set their goals in their Fitbit account either through the web site or mobile application. This help article explains how they can do this, https://help.fitbit.com/articles/en_US/Help_article/1955.htm. If they need assistance, the users can contact our support team.