01-27-2016 23:38 - edited 01-28-2016 00:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-27-2016 23:38 - edited 01-28-2016 00:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi,
We are migrating our Fitbit API to oAuth2 with Implicit Grant Flow (calling directly from iOS app). Since we cannot embed the authentication page into a UIWebView and SFSafariViewController class only supports iOS 9.0, we are redirecting our users to the default Safari app.
However 9 of the 10 times we get a "Cannot Open Page: Safari cannot open the page because the address is invalid" which is quite frustrating. If we run the same authentication url in a desktop browser then it will be fine. (sample url: https://www.fitbit.com/oauth2/authorize?client_id=229CW4&response_type=token&redirect_uri=wokamonFit...)
Please advise.
Thank you!
Wokamon
Answered! Go to the Best Answer.
Accepted Solutions
01-30-2016 08:22 - edited 01-30-2016 08:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-30-2016 08:22 - edited 01-30-2016 08:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@JeremiahFitbit Yes you are right. The Safari is not throwing the error against Fitbit's authentication url but my URL Scheme.
After some research, I found this: http://stackoverflow.com/questions/27739442/ios-safari-does-not-recognize-url-schemes-after-user-can...
If a user chooses 'Cancel' when Safari responds to the URL Scheme with the 'Open App?' popup, Safari will display 'Cannot Open Page' error if the user access the same URL Scheme. The solution is to reboot Safari.
I hope Apple will fix this problem in a future patch 😞

01-28-2016 11:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-28-2016 11:05
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
I don't think this is an error related to loading the OAuth 2.0 authorization page, otherwise we'd be getting tons of reports.
If you have already authorized the app, you will be immediately redirected to your redirect_uri. I'm guessing the problem is that iOS doesn't recognize your redirect URI.
01-28-2016 20:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-28-2016 20:28
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm using a URL scheme so that my call back url can redirect users back to the app. Are we allow to do that?

01-28-2016 20:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-28-2016 20:34
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I've just set a http url for my redirect_url and it still gives me the same error. Just to calrify that this error does not happen 100% of the time, and it works perfect when there's no error.
Also I'm accessing the API from China, could GFW be a potential reason?

01-29-2016 09:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-29-2016 09:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Wokamon wrote:
I'm using a URL scheme so that my call back url can redirect users back to the app. Are we allow to do that?
Yes, you're allowed to do that. Can you confirm if this error happens when you are redirected away from the authorization page?

01-29-2016 09:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



01-29-2016 09:54
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Wokamon wrote:
I've just set a http url for my redirect_url and it still gives me the same error. Just to calrify that this error does not happen 100% of the time, and it works perfect when there's no error.
Also I'm accessing the API from China, could GFW be a potential reason?
Related to your other topic, the China GFW may be the problem here, too. If Mobile Safari cannot establish a secure connection to www.fitbit.com, this may be the error that it displays.

01-30-2016 08:22 - edited 01-30-2016 08:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-30-2016 08:22 - edited 01-30-2016 08:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@JeremiahFitbit Yes you are right. The Safari is not throwing the error against Fitbit's authentication url but my URL Scheme.
After some research, I found this: http://stackoverflow.com/questions/27739442/ios-safari-does-not-recognize-url-schemes-after-user-can...
If a user chooses 'Cancel' when Safari responds to the URL Scheme with the 'Open App?' popup, Safari will display 'Cannot Open Page' error if the user access the same URL Scheme. The solution is to reboot Safari.
I hope Apple will fix this problem in a future patch 😞

03-17-2016 02:28 - edited 03-17-2016 02:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

03-17-2016 02:28 - edited 03-17-2016 02:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi. I had the same problem. Once cancelled, it would give that error.
What I did was sending an extra parameter with a timestamp, so Safari would not cache it. So after the last param, I added a foo param with the number of milliseconds since midnight January 1, 1970. I use as3, but this should be readable for all developers:
var foo:Number = new Date().time; //The number of milliseconds since midnight January 1, 1970
var urlRequest:URLRequest = new URLRequest(url+"&foo="+foo);
Where url is the url for oAuth2

10-20-2017 10:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-20-2017 10:13
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This is because you have not properly added redirect_url in info.plist file.
Say you have placed yourBundle.fitbit:// in your Callback URL in fitbit dashboard then
in your application info.plist
add url type yourBundle.fitbit and in LSApplicationQueriesSchemes add yourBundle.fitbit://
Hope this will work.
Thanks

01-21-2018 22:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-21-2018 22:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
My call back url is https://ng in my fitbit account. So my question is how I can set url schemes for "https://ng" in info.plist of my application. Because safari does not open the application through this link.

