Auth0 Home Blog Docs

Phonegap Authorisation Error On Callback

mobile
callback

#1

I’m building a mobile application with Phonegap and Framework7. I am attempting to add user authentication with Auth0 having followed the tutorials here and and here.

I have the InAppBrowser and all auth0 files installed successfully. I have all my client ID and domains etc correctly entered in.
When I click the login button I am taken off to the hosted login page, my login is remembered so I click my email address and this is where I get the error. The InAppBrowser reports “web page not available https://matchday-app.eu.auth0.com/login/callback? [letters and numbers presumably the access token] could not be loaded net::err_unsafe_redirect.”

The weird thing is Phonegap runs on the desktop and mobile and the desktop one logs in perfectly with no problems.
The Auth0 logs show a sucessful login too (from the phone) so I think it’s just the redirect (callback?) after login which isn’t working, but I have no idea why.

I have scoured the internet for others with this problem and come up with nothing so I would greatly appreciate any help, feedback, suggestions.

Please let me know if there’s any further information required.

Thanks in advance.

Code can be found here: https://github.com/ellis-sutehall/matchday

Allowed callbacks: file:///android_asset/www/index.html, file:///data/user/0/com.adobe.phonegap.app/files/phonegapdevapp/www/index.html#, https://matchday-app.eu.auth0.com/mobile, http://192.168.0.204:3000/#


#2

Although this should not be relevant to the error in question it’s worth noting that the PhoneGap quickstart is community maintained and may not be up to date. The reason I mention this is that the use of InAppBrowser is not recommended and has been replaced by the use of auth0-cordova as seen in some other quickstarts.

Having said that and going back to the error in question you seem to have added the https://matchday-app.eu.auth0.com/mobile callback in the application settings like instructed in the quickstart, but then the code is making use of window.location.href to set the redirect URI instead of the previous URL so at first glance this is unexpected although I admit I never used the InAppBrowser approach that much to say this would be for sure the problem.


#3

Thanks very much for taking the time to have a look and help me it’s greatly appreciated. I haven’t yet had time to implement your suggestions but I will do and feed back soon.

Having read everything I could on the subject before posting my question I am surprised I had not come across anything saying that the way described (using the inappbrowser) was no longer recommended.

I shall look into the new way as well and see if I have more luck.


#4

So I have gone about this in the new way you suggested and followed the tutorial here.

Annoyingly, I have still been unable to get it to work. I have installed SafariViewController and can confirm that is working.

However, when I compile all the files (using Webpack) I get an error:

App.js:139 Uncaught TypeError: Cannot read property ‘content’ of null

Are you able to help? I have updated the relevant files on the same GitHub link.

As before, any guidance greatly appreciated.


#5

Messed up the link in previous comment, this is the guide: https://auth0.com/docs/quickstart/native/cordova/01-login

Full error:
App.js:139 Uncaught TypeError: Cannot read property ‘content’ of null
at App.render (App.js:139)
at App.resumeApp (App.js:133)
at App.run (App.js:78)
at Channel.main (index.js:12)
at Channel.fire (cordova.js:777)
at cordova.js:231


#6