10-14-2016 15:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-14-2016 15:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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

- Labels:
-
JavaScript
-
OAuth 2.0
-
Subscriptions API
10-14-2016 15:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



10-14-2016 15:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@alevy01 How are you forming the request?

10-14-2016 16:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-14-2016 16:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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) {})

10-18-2016 17:36 - edited 10-19-2016 11:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



10-18-2016 17:36 - edited 10-19-2016 11:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@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

