nativescript-advanced-webview icon indicating copy to clipboard operation
nativescript-advanced-webview copied to clipboard

Android: OAuth Flow via Schemes doesn't work in the new version

Open vtjon opened this issue 7 years ago • 7 comments

In the latest version (2.0.2), it appears that something broke or changed with regards to redirecting to a custom scheme. I use the webview for an OAuth login flow that redirects to a custom scheme that relaunches the app. When this happens, the browser shows ERR_UNKNOWN_URL_SCHEME. There is some discussion here about a similar issue but it's relatively old: https://github.com/EddyVerbruggen/Custom-URL-scheme/issues/156

I don't have a repo of the issue but there were some errors related to the sandbox. Any ideas what changed in the latest release that could have affected this?

vtjon avatar Mar 06 '18 15:03 vtjon

@vtjon it opens a webview if if device does not have google chrome installed

triniwiz avatar Mar 06 '18 15:03 triniwiz

I think I got lazy with my wording. I meant Chrome Custom Tabs for the OAuth login flow. It works again when I go back to version 2.0.0. Chrome is installed. I will say, it does look different though like it defaulted to a webview for some reason (i.e., no URL bar or close X). I just tried to open https://www.google.com and it opens in the Chrome version. It must be switching over to a webview during the redirect cycle.

vtjon avatar Mar 06 '18 17:03 vtjon

It seems like it worked this time. Maybe I had the old AAR file or something. I will reopen if it happens.

vtjon avatar Mar 06 '18 17:03 vtjon

@triniwiz I think I might have figured out what is going on though I'm not sure exactly why. To recap:

  • I use an OAuth flow that ultimately redirects back to a custom scheme that is supposed to be captured by an intent setup on my app
  • During the OAuth flow, if I have to log into the provider (i.e., Facebook), the redirect works as it did in version 2.0.0.
  • If I am already logged in, the redirects (302) happen without any user interaction. I can see in logcat that the intent is triggered
  • If I restart my app, it will immediately pick up the intent

I think ultimately, my app is being sent to the background. Upon research, I ran across this: https://stackoverflow.com/a/38494130/62686

I looked at your fancy webview repo and it doesn't appear to call the warmup function. Is this something straightforward to add?

vtjon avatar Mar 06 '18 19:03 vtjon

I had this similar issue. I set up a fresh webview plugin myself that uses Chrome Custom Tabs. You can try this https://www.npmjs.com/package/nativescript-awesome-webview till the issue is not fixed on this repo

championswimmer avatar Jul 27 '18 14:07 championswimmer

@vtjon it should it’s set to true in the init

triniwiz avatar Jul 29 '18 05:07 triniwiz

@vtjon can you try this other option? https://github.com/proyecto26/nativescript-inappbrowser Let me know 👍

jdnichollsc avatar May 11 '19 05:05 jdnichollsc