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

Adding a subscriber to the developer account

ANSWERED
* I originally posted this in the SDK section but meant to post it here. Couldn't figure out how to delete the post.
 
A few others and myself have recently inherited an application that uses the Fitbit to access information about a user that has given our application permission to see their uploaded information to the Fitbit database.
 
Since the project was started a few years back and multiple teams have worked on this application, the credentials to the original developer account on Fitbit were lost. Since then, I have created another developer account and implemented all of the new Fitbit credentials to use for receiving information such as the Authorization Code to add a new subscriber to our database.
 
Right now, our application can successfully add a user to our database along with the Fitbit access token, refresh token, user ID returned from Fitbit, etc. The problem now however is that we cannot manage to receive anything but a 400 Bad Request back from Fitbit when trying to add a subscriber to our application. The API is written in Flask and below is the request we are currently creating to try and send the request to for the subscription. We had to add in the content-length since the last group didn't have it in there since it was before that header was required. I am also using Postman to test these endpoints.
 
authHeader = "Bearer " + newCaregivee.fitbitAccessToken
header = {"Authorization": authHeader, "content-length": "0"}
    str(newCaregivee.caregiveeID) + ".json"
 
My first thought is that we are using a '-' to simulate a currently logged in user. Should I change that to the encoded userID of the user for testing? If so, how would I get that? The page I have been referencing: Create Subscription 
Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Carebit 

 

Thank you for providing the information.  Before you create subscriptions, you need to have a subscriber configured for your application.  When you create a subscription, you link it to a specific subscriber which receives the notifications.

 

See https://dev.fitbit.com/build/reference/web-api/developer-guide/using-subscriptions/#Subscribers

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
0 Votes
4 REPLIES 4

Hi @Carebit 

 

Is there an error message that accompanies the 400 Bad Request error?   400 is a generic error and the message will provide more information to the problem.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Unfortunately it only returns 400 bad request from what I can tell. It made me think something was wrong in my request but everything seems to be in order so I am lost on how to move forward and get a subscription ID to return. We are testing on a user that is a brand new account with no Fitbit linked to them currently. Could that be the problem?

 

So far we get a good response from Fitbit to generate tokens and a user_id for the Fitbit user. When I plug in the access token and user_id received from Fitbit that I verified are the same ones that were given, it just returns a 400 Bad Request.

Carebit_0-1662653681740.png

Carebit_1-1662653695670.png

 

 

Best Answer
0 Votes

@Carebit 

 

I will send you a private message to collect some information from you.   Hopefully, this will help me figure out the problem.

 

Best,

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @Carebit 

 

Thank you for providing the information.  Before you create subscriptions, you need to have a subscriber configured for your application.  When you create a subscription, you link it to a specific subscriber which receives the notifications.

 

See https://dev.fitbit.com/build/reference/web-api/developer-guide/using-subscriptions/#Subscribers

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes