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

Authorize on iOS

ANSWERED

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:

https://www.fitbit.com/oauth2/authorize?response_type=token&client_id=123ABC&scope=activity%20settin...

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

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You will need to register your own URL scheme and create a URL path that your app will be able to understand.

View best answer in original post

Best Answer
0 Votes
6 REPLIES 6

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...

Best Answer
0 Votes

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.

Best Answer
0 Votes

You will need to register your own URL scheme and create a URL path that your app will be able to understand.

Best Answer
0 Votes

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

Best Answer
0 Votes

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

Best Answer
0 Votes

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

Best Answer
0 Votes