Twitter Login Not Working On Android

Hi.

We have a problem where Twitter login is not working on Android. We can test it using the “Try” button in Auth0 dashboard successfully. We can also log in on a web browser, but not in Android as we get the following error:

“Cannot GET /android/io.shoutapp.shout/callback”

upon pressing the twitter button, before even being presented with a login page for twitter (possibly because I’m already logged in with twitter on the phone).

Our login code is:

        Auth0 auth0 = new Auth0(getString(R.string.com_auth0_client_id), getString(R.string.com_auth0_domain));
    auth0.setOIDCConformant(true);
    lock = Lock.newBuilder(auth0, callback)
            .withAudience("https://api.shoutapp.io/")
            .build(this);
    startActivity(lock.newIntent(this));

:wave: @shoutapp

Is it just the Twitter login that is not working on your Android application? Do you have other logins that are working?

Can you check if you have a LockCallback implementation? If you could please share that here it might help.

Correct, It’s just twitter. Facebook and google work fine, as do standard login.

Here is the callback:

private LockCallback callback = new AuthenticationCallback() {
    @Override
    public void onAuthentication(Credentials credentials) {
        //Authenticated
        jwt = new JWT(credentials.getIdToken());
        androidAuthName = jwt.getClaim("name").asString();
        androidAuthToken = credentials.getAccessToken();
        loggedIn = true;
        webView.loadUrl(String.format(SHOUT_APP_URL, androidAuthToken, androidAuthName, URL_PARAMS));
    }

@shoutapp thanks for sharing the LockCallback!

From the error message you provided in your first message, “Cannot GET /android/io.shoutapp.shout/callback”, it could be that the response was supposed to be handled by the app and not the browser, which may happen if the browser is opening all https schemas by default or if the “Open with” popup showed up and the browser was selected. You could try using a custom scheme.

Is this a continuous issue with Twitter or does it only happen sometimes? If it’s the later is it a bit random even on the same device? Any particular version of Android?

@kimcodes just to add, the app is, as you can tell from the code, a webview. That callback error is actually appearing in the webview, not in the browser if that’s what you mean? Which i think is correct, as the google and facebook login stuff appears to work within the app, calling a “custom chrome tab”

Also, It seems to be all versions of android with Twitter all of the time

Gotcha! What version of Lock.Android are you using in your build.gradle file?

1 Like

Looks like I was just setting it to ‘com.auth0.android:lock:2.+’ - which I believe compiled to 2.8.3.

(p.s thank you for continuing to help with this)

@kimcodes Looks like I was just setting it to ‘com.auth0.android:lock:2.+’ - which I believe compiled to 2.8.3.

(p.s thank you for continuing to help with this)

@shoutapp great! thanks for checking that for me. I apologize for the delay I must have missed the notification. Let me give it a try on my end. Ill get back to you shortly.

1 Like

@kimcodes That would be great, thank you :slight_smile:

@kimcodes Any luck?

Wayne

@shoutapp apologize for the delay! I wasn’t able to reproduce the issue for my version, but it may just be a simple difference. Let me reply to your DM!

FYI to anyone reading this topic. @kimcodes kindly solved this issue by pointing out that we could set the scheme to a custom and arbitary string, as long as it matched in; the manifest, the lock initialisation code, and the dashboard callbacks.

1 Like