问题
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.
回答1:
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.
回答2:
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()
来源:https://stackoverflow.com/questions/49516412/chrome-custom-tab-gets-sometimes-stuck-at-blank-screen-during-login