Where is the subscription ID associated with a fitbit user? I see in the docs that we provide a subscription ID when subscribing, but there is no association with a particular user account.
Answered! Go to the Best Answer.
Best AnswerTo answer my own question, the association between the user and subscription is made because the subscription is called with the user's Bearer token. The API doc is not very clear about that, and we were making the mistake of not seeing where to provide the user ID in a server (ours) to server (fitbit) call.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
We don't have existing subscriptions, we are trying to setup subscriptions. There doesn't seem to be an association between a user and a subscription ID in the API calls, that's what I'm looking for. So in the API example 320 is used for the subscription ID. How is that related to a user? We can certainly relate that to a user ID on our side if needed, but it wouldn't mean anything to fitbit.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Your app defines the id for the subscription. We recommend a pattern that is useful to your application. The Fitbit user id is included in the notification, but you might use a different id for the user. Some app use a pattern of "myAppsUserId-fitbitUserId-resourceCollection". The subscription id is also returned in the notification.
Best AnswerI must be misunderstaning the API doc. The graphic at the top says "Add a subscription for the user to get notifications and return a response in the format requested.". Are you saying we don't add a subscription per user? So we automatically get notifications for all our users?
Best AnswerTo answer my own question, the association between the user and subscription is made because the subscription is called with the user's Bearer token. The API doc is not very clear about that, and we were making the mistake of not seeing where to provide the user ID in a server (ours) to server (fitbit) call.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@DavidHolmes wrote:
To answer my own question, the association between the user and subscription is made because the subscription is called with the user's Bearer token. The API doc is not very clear about that
Correct—all* API requests are made on behalf of the person who authorized your app.
* The only exceptions are a few endpoints for general resource (loggable food and activity types) listings and search.
Best AnswerThanks Jeremiah. It seems extremely obvious in hindsight, and would have never come up for any other calls for user data. But working on the subscription in isolation it's not so obvious.
Best AnswerSp does that mean that when the user authentication is complete, we should send another POST request for the subscription with the user token as the subscriber-id. Also what happens when the access token is refreshed.
Best AnswerYes I am wondering the same question as GlobeTrekkerDev
Best Answer