08-05-2015 03:18
08-05-2015 03:18
Hello,
I am developing an iOS application which uses the Fitbit Api. I have a registered app in the Fitbit Developers. As read on the
https://dev.fitbit.com/docs/oauth2/
page, I should use a browser when authorize my app with the users credentials. So I should open the url in Safari, which is the following:
Earlier I used a WebView for this purpose, but it seems that I have to change it to a browser. My qquestions are:
1. How to receive the authorization token if the user authorized my app? I use Objective C.
2. Using an OAuth2 lib is mandatory or only recommended? If I must use one, could you recommend a library which is ARC compatible and can be used in a production app?
Thank you
Dávid
Answered! Go to the Best Answer.
08-06-2015 12:28
08-06-2015 12:28
You will need to register your own URL scheme and create a URL path that your app will be able to understand.
08-05-2015 12:13
08-05-2015 12:13
OAuth 2.0 libraries are recommended, but not required. You could also use a standard HTTP library and construct the headers manually.
In order for the user to be redirected back to your iOS from Mobile Safari, you much use an app URL scheme. Apple's documentation: https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/Introduction/Intr...
08-06-2015 03:06
08-06-2015 03:06
Thank you. However, I am not sure what the exact URL that should be entered as a callback for my registered app on the Fitbit website.
08-06-2015 12:28
08-06-2015 12:28
You will need to register your own URL scheme and create a URL path that your app will be able to understand.
08-12-2015 07:06
08-12-2015 07:06
Thank you, I could solve my issue.
Now I can authenticate a user, and make requests to read their data.
However I am not sure how to log in another user on the same device to my app. Everytime when my app tries to connect to Fitbit, the access code will be received for the user who was logged in before.
My access code was expired some mins ago, and I only could allow or deny access, but could not enter other user details. Is there any other way than revoke access for that app on www.fitbit.com? I tried to uninstall and reinstall the app on my iPhone.
On other i devices the log in page appears of course.
Thank you
08-12-2015 11:11
08-12-2015 11:11
You can revoke access to an application in your Fitbit user settings at https://www.fitbit.com/user/profile/apps
Also, check out the 'prompt' URL parameter for the OAuth 2.0 authorization page. It will allow you to force a user to sign in or re-authorization. https://dev.fitbit.com/docs/oauth2/#obtaining-consent
01-11-2016 15:56 - edited 01-11-2016 15:57
01-11-2016 15:56 - edited 01-11-2016 15:57
Hello,
@DavidNemeth I saw that you were able to integrate OAuth2 with fitbit it would be great if you could provide me some solution to my issue posted here:
https://community.fitbit.com/t5/Web-API/Authorization-on-iOS-failing/td-p/1116389
Thanks in advance
Amit