I'm trying to implement the fitbit api for a small Node.JS application. I'm using the passport-fitbit npm package in order to deal with the oauth authentication. I managed to log in and get the access token without any problem but my issue here concerns the API calls I have to do.
For instance : I want to get all the activities from my account so I just have to send a GET request with the following uri : http://api.fitbit.com/1/user/-/activities/date/2014-24-08.json but I can't manage to fill the http header of this request.
Here's my piece of code :
app.get('/fitnessActivities', function (req, res) { request.get({ uri: FB_URL + '/1/user/-/activities/date/2014-24-08.json', headers: { 'Accept-Locale': 'fr_FR', 'Accept-Language': 'en_GB', 'Authorization': 'OAuth oauth_consumer_key="myconsumerkey",oauth_signature_method="HMAC-SHA1",oauth_version="1.0"' } }, function (err, resp, body) { res.json({ feed: JSON.parse(body) }); }); });
The documentation says that I need the following header in order to GET the information I want :
Host: api.fitbit.com Authorization: OAuth oauth_consumer_key="fitbit-example-client-application", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1270248082", oauth_nonce="161822064", oauth_callback="http%3A%2F%2Fexample.fitbit.com%2Fapp%2FcompleteAuthorization", oauth_signature="Omf%2Bls2gn%2BDlghq245LRIyfMdd8%3D" oauth_version="1.0"
My problem is that I can't manage to get all the fields ( especially timestamp, nonce, signature ). How can I manage to get those information in order to be able to authorise my request ?