Description
This is the scenario:
Configure the AppAuth example as usual (client_id, redirect_uri, authorization_scope and discovery_uri, appAuthRedirectScheme). Run the app, login with some user so that Chrome has a session with the Authorization Server, then hit "Sign out" (which only removes the app's state, not the browser session).
Then:
- Hit "Start Authorization". => Browser tab opens, but the redirect back to the app fails and the browser tab stays open. The log shows the infamous "Navigation is blocked" error from chromium.
- Close the browser tab manually.
- Hit "Start Authorization" again. => This time, the browser tab shows briefly, and then the redirect succeeds, authorization code comes back to the app and is exchanged for a token.
- Hit "Signout" again. Now go back to 1. and repeat - the result is the same each time.
After a lot of digging, I found that when the app starts and/or user hits Signout, the browser tab is already prewarmed with an actual auth request, and when the user subsequently hits "Start Authorization", Chrome does NOT pass the actual auth request to the Authorization Service - but instead it tries to return immediately followed by "Navigation is blocked".
Eventually, it appears that the "Navigation is blocked" error can be avoided by either:
a) Not warming up the browser tab.
b) Warming up the browser tab but with an empty query string (no client_id,...).
c) Warming up the browser tab but add e.g. a "warmup=true" part to the query string.
FYI, option c is done by changing the following line in LoginActivity.warmUpBrowser:
Uri realAuthUri = mAuthRequest.get().toUri();
Uri dummyAuthUri = realAuthUri.buildUpon().appendQueryParameter("warmup","true").build();
CustomTabsIntent.Builder intentBuilder =
mAuthService.createCustomTabsIntentBuilder(dummyAuthUri);
Any of these actions ensures that an actual authorization request is made to the Authorization Service, and no more "Navigation is blocked".
=> Is this behavior to be expected? Is there anything the Authorization Service should do to avoid it?
=> What is the recommended approach: a, b or c ? or perhaps something else still?