Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome custom tab gets sometimes stuck at blank screen during login

We recently integrated AppAuth into our application to automate the OAuth2 authorization code flow. When user wants to login, he is first redirected to our auth server, where he proceeds with the login, and then gets redirected back to the application.

We use chrome-custom-tabs to for opening the login page (AppAuth). The problem is that it sometimes gets stuck at a blank screen (chrome tab displays just blank page without the rendered site or redirect). This happens when the user already has a session in the browser so the tab should close automatically and redirect user back to the application (authenticated). It does not behave consistently and we only experience this issue sometimes (~50/50).

I am happy to add some code but don't know where to start (trying to avoid wall of text). Is there a known issue or caveat?

We tried switching contexts as described here but kept experiencing the same issue.

like image 401
Smajl Avatar asked Mar 27 '18 15:03

Smajl


2 Answers

Lead maintainer of AppAuth here. This is most likely happening because the authorization redirect is happening without any user interaction. Chrome enforces a policy that it will only send redirects to your app if the redirect was triggered by a user action, such as submitting a form that redirects or clicking on a link.

If the IDP you are integrating with supports it, you can pass "prompt=consent" as a parameter to force user interaction. Alternatively, you can set up an intermediary page that captures the redirect and displays a "welcome back" message, with a link or button to return to your app.

like image 169
iainmcgin Avatar answered Sep 28 '22 15:09

iainmcgin


Another way is to make the user, use the login screen each time.

just add ".setPrompt("login")" to the authRequestBuilder.

so mine will be:

val authRequest = authRequestBuilder
        .setPrompt("login")
        .build()
like image 39
Christian Rasmussen Avatar answered Sep 28 '22 13:09

Christian Rasmussen