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

Adding A Subscription

Hello,

 

I have been able to verify a Subscriber with my unique subscriber endpoint. I cannot figure out how to add a subscription though. Currently I have the users authenticating with my app through OAuth2 using the npm module 'fitbit-oauth2'. I am currently trying to use the npm module 'requests' to send the POST request to add a subscriber. We are currently omitting the collection-path as we require all scopes. We are also currently using the Fitbit ID as the subscription id. 

 

The format I am currently using for the POST is https://api.fitbit.com/1/user/{Fitbit_ID}/apiSubscriptions/{Fitbit_ID}.json

 

When running the request above we get: 

{
    "errors": [
        {
            "errorType": "invalid_client",
            "message": "Invalid authorization header format. Visit https://dev.fitbit.com/docs/oauth2 for more information on the Fitbit Web API authorization process."
        }
    ],
    "success": false
}

 

Looking forward to hearing back,

-Stress Health Team

Best Answer
0 Votes
3 REPLIES 3

@alevy01 How are you forming the request?

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes

Current just using the npm 'request' module, so:

 

request.post({url:'https://api.fitbit.com/1/user/{Fitbit_ID}/apiSubscriptions/{Fitbit_ID}.json'}, function(err, httpResponse, body) {})

 

Best Answer
0 Votes

@alevy01 We were able to replicate the error using the 'request' library; however, it works fine when we use the 'fetch' library. It might be an issue with the request library.

 

EDIT:

request library works, what header are you setting?

 

Should look like this:

Authorization: Bearer accesstokenforuser

 

Andrew | Community Moderator, Fitbit

What motivates you?

Best Answer
0 Votes