03-24-2015 06:02
03-24-2015 06:02
Hi,
I am trying to build an iOS app that uses the FitBit API. I understand I can use OAuth as per the guidance in http://stackoverflow.com/questions/14036210/ios-http-request-example. Two questions:
1. How can I convert GET /1/user/-/activities/date/2010-04-02.json HTTP/1.1 into an https URL string?
2. How do I get the right user ID for a user of my app? Is it just the same FitBit ID that a FitBit user uses when the register to use FitBit?
Answered! Go to the Best Answer.
03-24-2015 08:46 - edited 03-24-2015 08:47
03-24-2015 08:46 - edited 03-24-2015 08:47
@michaelnares wrote:So as long as the user is logged in on the browser on the phone, it should work?
No. If you send a valid oauth access_token in the header of the API request it will work.
https://wiki.fitbit.com/display/API/API+Explorer
Read this page very several times: https://wiki.fitbit.com/display/API/OAuth+Authentication+in+the+Fitbit+API
I know you don't want to read the page above, but reading it and fully understanding it first will save you a lot of time.
Search Google for ios oAuth and FitBit tutorial or something for a step-by-step tutorial.
03-24-2015 08:31 - edited 03-24-2015 08:32
03-24-2015 08:31 - edited 03-24-2015 08:32
@michaelnares wrote:Hi,
I am trying to build an iOS app that uses the FitBit API. I understand I can use OAuth as per the guidance in http://stackoverflow.com/questions/14036210/ios-http-request-example. Two questions:
1. How can I convert GET /1/user/-/activities/date/2010-04-02.json HTTP/1.1 into an https URL string?
2. How do I get the right user ID for a user of my app? Is it just the same FitBit ID that a FitBit user uses when the register to use FitBit?
It would just be https://api.fitbit.com/1/user/-/activities/date/2010-04-02.json
Rather than passing in the user you would leave the dash so that it requests the current logged-in user.
You might want to look into this service which aims to simplify connecting to APIs: http://live.temboo.com/library/Library/Fitbit/
03-24-2015 08:39
03-24-2015 08:39
So as long as the user is logged in on the browser on the phone, it should work?
03-24-2015 08:46 - edited 03-24-2015 08:47
03-24-2015 08:46 - edited 03-24-2015 08:47
@michaelnares wrote:So as long as the user is logged in on the browser on the phone, it should work?
No. If you send a valid oauth access_token in the header of the API request it will work.
https://wiki.fitbit.com/display/API/API+Explorer
Read this page very several times: https://wiki.fitbit.com/display/API/OAuth+Authentication+in+the+Fitbit+API
I know you don't want to read the page above, but reading it and fully understanding it first will save you a lot of time.
Search Google for ios oAuth and FitBit tutorial or something for a step-by-step tutorial.
03-25-2015 02:44
03-25-2015 02:44
Really helpful, many thanks.