Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Subscriptions: user to subscription ID association

ANSWERED

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.

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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, and we were making the mistake of not seeing where to provide the user ID in a server (ours) to server (fitbit) call.

View best answer in original post

Best Answer
0 Votes
9 REPLIES 9

If you want to see the subscriptions your application has created for a user, use the endpoint documented here.

Best Answer
0 Votes

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.

 

https://api.fitbit.com/1/user/-/apiSubscriptions/320.json

Best Answer
0 Votes

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 Answer
0 Votes

I 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 Answer
0 Votes

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, 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
0 Votes

@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 Answer
0 Votes

Thanks 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 Answer
0 Votes

Sp 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 Answer
0 Votes

Yes I am wondering the same question as GlobeTrekkerDev

Best Answer
0 Votes