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

How to get started

I have downloaded the sample app and got it running but can go no further. The documentation kind of tells what needs to be done, but very little on how to do it. There are many questions but I will start with these.  So how does my application make an http request and send a special authorization header? Also what part of the sample app code is considered the library that I would need to include in my application? Where do I find the OAuth 1.0a library for my preferred language and framework? How do I create a user authorization flow to obtain user consent?

 

Thanks in advance for any light you can shed on this very complicated process.

Best Answer
0 Votes
26 REPLIES 26

I spent the last 1 hour to write a code, i wrote 2 version. Here is one, but i cant test it:

                    var request = (HttpWebRequest)WebRequest.Create("https://api.fitbit.com/1/user/" + encoded_userid + "/body/log/weight.json");

                    var postData = "weight=100.0";
                    postData += "&date=2015-09-09";
                    var _data = Encoding.ASCII.GetBytes(postData);

                    request.Headers["Authorization"] = "Bearer " + accesmodell.access_token;
                    request.Method = "POST";
                    request.ContentType = "application/x-www-form-urlencoded";
                    request.Accept = "application/json";
                    request.ContentLength = _data.Length;

                    using (var stream = request.GetRequestStream())
                    {
                        stream.Write(_data, 0, _data.Length);
                    }

                    var _response = (HttpWebResponse)request.GetResponse();

 [i'm the same user, just on another test account :P]

Best Answer
0 Votes

Wow!!! I can't thank you enough. It worked. I had tried variations of this exact same code so many times with no success. It apparently comes down to the specific combination of encoding type, content type, and accept that the fitbit API requires. It is beyond my comprehension as to why this is not included in the documentation. It would save weeks of work trying to hit this exact combination. Thanks again for taking the time to help me.

Best Answer
0 Votes

No problem, we will use this code later 🙂

Best Answer
0 Votes

Where do you download the sample app from?

Best Answer
0 Votes

s i kind of an older thread.  The new guidlines for FitBit are to use a Chrome Cutom Tabs for the "WebView."  Is this taken care of using this plug in?

Best Answer
0 Votes

s i kind of an older thread.  The new guidlines for FitBit are to use a Chrome Custom Tabs for the "WebView."  Is this taken care of using this plug in?

Best Answer
0 Votes

Where does one find sample apps? I'm not seeing anything in the API documentation.

Best Answer
0 Votes