java – Webpage not available in Cordova Android app

I am tearing my hair out trying to figure out what might be causing this problem.

I’ve got the following error message on a simulator in Android studio:

Webpage not available

I am using the identity management system Keycloak – I’ll get back to that in a bit.

I have tried changing my CSP to be very permissive:

  <meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-eval' 'unsafe-inline'; media-src *; img-src 'self' * data:"
  />

I have installed inappbrowser, I have set my intents and allow-navigations pretty liberally in my config.xml:

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-intent href="gap://*" />
<allow-intent href="APPNAMEHERE://*/*" />
<allow-intent href="fb://*/*" />
<allow-intent href="http://stage.APPNAMEHERE.com://*/*" />
<allow-intent href="https://stage.APPNAMEHERE.com://*/*" />
<allow-navigation href="https://localhost/*"/>
<allow-navigation href="http://localhost/*"/>
<preference name="Hostname" value="localhost" />
<preference name="Scheme" value="https" />
<preference name="MixedContentMode" value="0" />
<access origin="*" />
<allow-navigation href="*" />
<allow-navigation href="localhost://*/*" />
<allow-navigation href="APPNAME://*/*" />
<allow-navigation href="fb://*/*" />
<allow-intent href="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="*" />

Basically I have tried to make this app as permissive as possible, and still no luck authenticating.

But there’s something weirder.

I have another, completely unrelated app, but which also uses this same identity management system. I decided, on a lark, because I was desperate to try connecting against that service here, and it works flawlessly – no issues.

I tried exporting the client from the other Keycloak (a bunch of configuration settings) and using them with minor changes, and no dice. Still the same error.

I am just about tearing my hair out at this point, I’ve been continuously trying different things and clicking “login” for hours with the exact same result.

What could possibly be preventing me from logging in?

Note, there’s an iOS app that works perfectly on this same setup, so it’s not the setup.

I’m connecting via OIDC, if that helps anyone.

I’m sorry I can’t provide more information, I wish I could find something, anything to grasp at, but I’m completely lost here, it just seems to not be able to find localhost, no matter what I try.

Android console (there is nothing special I am seeing in the Chrome inspector):

2019-08-31 10:56:42.002 12062-12191/com.companyname.appname D/InAppBrowser: target = _blank
2019-08-31 10:56:42.003 12062-12062/com.companyname.appname D/InAppBrowser: in blank
2019-08-31 10:56:42.054 12062-12164/com.companyname.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2019-08-31 10:56:42.054 12062-12164/com.companyname.appname E/eglCodecCommon: glUtilsParamSize: unknow param 0x000088ef
2019-08-31 10:56:42.168 12062-12170/com.companyname.appname D/EGL_emulation: eglMakeCurrent: 0xf0677ba0: ver 3 0 (tinfo 0xd6778770)
2019-08-31 10:56:42.325 12062-12170/com.companyname.appname D/EGL_emulation: eglMakeCurrent: 0xf0677ba0: ver 3 0 (tinfo 0xd6778770)
2019-08-31 10:56:42.501 12062-12170/com.companyname.appname D/EGL_emulation: eglMakeCurrent: 0xf0677ba0: ver 3 0 (tinfo 0xd6778770)

Note, I have replaced the company name of the company this is for with “companyname” and the app name with “appname”

EDIT:

I am also noticing this error when trying a very basic keycloak implementation (the toy example here: https://github.com/keycloak/keycloak/blob/master/examples/cordova/www/index.html) on my front end:

keycloak.js:1000 Uncaught (in promise) undefined
setError    @   keycloak.js:1000
(anonymous) @   keycloak.js:1261
Channel.fire    @   cordova.js:840
_eventHandler   @   inappbrowser.js:53
cb  @   inappbrowser.js:118
callbackFromNative  @   cordova.js:290
(anonymous) @   VM68:1

The code in question, in keycloak.js, pertains to creating a native promise:

function createNativePromise() {
    // Need to create a native Promise which also preserves the
    // interface of the custom promise type previously used by the API
    var p = {
        setSuccess: function(result) {
            p.success = true;
            p.resolve(result);
        },

        setError: function(result) {
            p.success = false;
            p.reject(result);
        }
    };

Could it possibly be related to inappbrowser?

EDIT 2: Digging deeper down…

The error is getting thrown here.

So my guess is that it’s due to my redirect url somehow being https://localhost rather than http://localhost, as this is what my redirect URI is.

                ref.addEventListener('loaderror', function(event) {
                    if (!completed) {
                        if (event.url.indexOf('http://localhost') == 0) {
                            var callback = parseCallback(event.url);
                            processCallback(callback, promise);
                            closeBrowser();
                            completed = true;
                        } else {
                            promise.setError();
                            closeBrowser();
                        }
                    }
                });

https://localhost/#state=3bc5b8e8-ee17-4c78-861c-6fa62f5e353b&session_state=43d5518d-c278-4245-b181-899783fd2c6b&code=8e50a9c0-d1a6-4ecd-8e91-e85d92350900.43d5518d-c278-4245-b181-899783fd2c6b.863570ca-9c62-41a5-97bb-33880fe6c62d

Even when trying:

keycloak.init({ onLoad: "check-sso", redirectUri: "http://localhost" })

I am still getting the redirect uri of https:// above, which I am strongly thinking is responsible for my error.

My strong guess at this point is that this may be related to a Keycloak (which uses Wildfly) configuration setting.

Facebook Comments

(Visited 10 times, 1 visits today)
Loading...