15

I am trying to get Auth0 working in Browser using

ionic run browser

I have followed the guides from Auth0. I am using

auth0-7.6.1.min.js

lock/10.10.2/lock.min.js

versions. navigation to Google login page happens, but the callback is failing with blank white screen. by call back I mean loading the

https://n00b.au.auth0.com/login/callback?state=blahblahblah...

url. which loads a white html with JavaScript that throws exeption

Uncaught can't find relay frame

in these lines of code

     onOpen: function(cb) {
        var o = "*";
        var msgTarget = isIE ? findRelay() : window.opener;
        if (!msgTarget) throw "can't find relay frame";

clearly a global window.opener property was expected to exist. knowing that this whole URL is served by Auth0, I can't find a way to figure out what is wrong.

I have checked the logs in Auth0 and it is all green from their perspective and shows successful login.

Any Idea why this is failing?

UPDATE: tested on iPhone and iOS Emulator and both only show blank white screen. Downloaded sample Auth0 project and has this issue without any modification. My guess is that it has something to do with InApp Browser plugin of Cordova opening the login page in a new safari window

n00b
  • 1,832
  • 14
  • 25
  • Just want to make sure you know window.opener is set automatically when you navigate to the page using window.open(url), right? See https://developer.mozilla.org/en-US/docs/Web/API/Window/opener – corolla Mar 01 '17 at 19:35

2 Answers2

1

I'm currently having problems with the lock opening the registration link in the safari browser instead of in the InAppBrowser. This could be the thing that breaks the callback as it makes you completely switch application to Safari.

I made have a temporary workaround so the sign up link opens in the InAppBrowser, see => App rejected by Apple because Auth0 signUpLink doesn’t open in Cordova InAppBrowser but in system browser (Safari)

You could maybe apply this to your login links to have them open in the InAppBrowser as well.

Community
  • 1
  • 1
Bryandh
  • 539
  • 1
  • 5
  • 22
1

Just want to make sure you know window.opener is set automatically when you navigate to the page using window.open(url).

See http://developer.mozilla.org/en-US/docs/Web/API/Window/opener

Update after comments:

Try <script>window.orgopen = window.open;</script> above ionic lib. Before starting auth0 login flow, do

window.ionicopen = window.open; 
window.open = window.orgopen;

Reset afterwards: window.open = window.ionicopen;

If but a mere hack, this might at least take an unknown out of the equation.

corolla
  • 5,386
  • 1
  • 23
  • 21
  • I don't use window.open here. I use a library by Auth0 called Lock which has a lock.show function. You are right though that probably they have some issue opening this in the right place – n00b Mar 02 '17 at 03:14
  • @n00b, gotcha. Assuming window.open is used by Auth0, it could be Ionic is overriding window.open, and in the process causing opener not to be set. Stuff like http://stackoverflow.com/q/38212479/495244 and https://forum.ionicframework.com/t/open-all-links-in-app-browser/66442/4 seems to indicate something of the kind. Note how the location.reload() apparently returns window.open to original. Could be you can grab the original window.open method in a script blog prior to loading ionic lib and then resetting it before the call to auth0 login. – corolla Mar 02 '17 at 09:11
  • I tried doing this, but without any success. Actually window.open had stayed the same after Ionic scrip loads: function open() { [native code] } – n00b Mar 20 '17 at 02:59