Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding onRedirectToURL callback (to support OAuth login without having to use custom URL scheme) #115

Open
sachingarg05 opened this issue Jul 2, 2018 · 4 comments

Comments

@sachingarg05
Copy link

Both iOS and Android now support callbacks for redirect navigation events. If support for these events is added in cordova-plugin-safariviewcontroller, then we will not have to use Custom-URL-scheme plugin to implement OAuth logins (or other related federated authorization options like SAML, WS-FED, ADFS, Auth0, Okta etc).

On iOS, at least since iOS11, we have safariViewController:initialLoadDidRedirectToURL which can be used to get access token without having to use the mycustomurl:// redirect URL.

On Android, we have CustomTabsCallback::onNavigationEvent which can used the same way.

Background:

We don't control all the federated services that we need to support in our app, so can't change the redirect URLs to include mycustomurl:// in some cases.

Also, we have multiple custom builds of same app. When cordova-plugin-safariviewcontroller tries to launch mycustomurl:// on a device with multiple apps installed all of which support mycustomurl:// - Android prompts user to select which of the installed apps to use to open it, and iOS picks one at random (usually the one which was last installed)

Due to these limitations, we need to continue using the old inappbrowser for now, although cordova-plugin-safariviewcontroller will be a better and more secure user experience.

If we can have a new onRedirectToURL event in cordova-plugin-safariviewcontroller, we will be able to use cordova-plugin-safariviewcontroller for devices with iOS>11, and continue using inappbrower only for iOS<=10 (till it drops off in another 2-3 years). I am not sure about android, but CustomTabsCallback::onNavigationEvent seems to be dependent only on support library version which means it might work on all versions of android that support custom tabs.

My apologies for opening this as an issue instead of a pull request. Looking at the code for this plugin, I can see how and where to update iOS code to add support for safariViewController:initialLoadDidRedirectToURL but the Android code seems more complicated. I tried updating Android code a bit for CustomTabsCallback::onNavigationEvent but it didn't get called.

@jdnichollsc
Copy link

@sachingarg05 it looks like you can't get the url with CustomTabsCallback::onNavigationEvent

@sachingarg05
Copy link
Author

Yes, that does seem to be the case, found this: https://bugs.chromium.org/p/chromium/issues/detail?id=543542

@jdnichollsc
Copy link

@sachingarg05 also, the onRedirectToURL of iOS is only executed when the browser is initialized, isn't it?

@sachingarg05
Copy link
Author

I didn't actually implement initialLoadDidRedirectToURL, is this what you are experiencing?

Searching around I found another option, but Apple seems to be suggesting using a customurlscheme:// with this - https://developer.apple.com/documentation/safariservices/sfauthenticationcompletionhandler?language=objc

I don't like the idea of using a customurlscheme:// especially when there are multiple apps that might be registered to use same customurlscheme://, and also because it requires changing the configuration on server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants