Fix Android WebAuth callback for system browser flows#15187
Merged
mattleibow merged 2 commits intomainfrom May 26, 2023
Merged
Conversation
This adds a flag to track if the web authentication flow was launched via custom tabs or the fallback, system browser. We were assuming it was always via custom tabs, and so the intermediate activity would be started which is not necessary or designed to compatible with the flow using the system browser. This changes the callback activity to properly route back to the intermediate activity for custom tabs initialized flows, and to just call the OnResume callback for other flows (system browser).
Contributor
|
Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines. |
mattleibow
approved these changes
May 19, 2023
rmarinho
pushed a commit
that referenced
this pull request
May 30, 2023
* Fix Android WebAuth callback for system browser This adds a flag to track if the web authentication flow was launched via custom tabs or the fallback, system browser. We were assuming it was always via custom tabs, and so the intermediate activity would be started which is not necessary or designed to compatible with the flow using the system browser. This changes the callback activity to properly route back to the intermediate activity for custom tabs initialized flows, and to just call the OnResume callback for other flows (system browser). * Auto-format source code --------- Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Contributor
|
/backport to net7.0 |
Contributor
|
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/5138834817 |
Contributor
|
@hartez backporting to net7.0 failed, the patch most likely resulted in conflicts: $ git am --3way --ignore-whitespace --keep-non-patch changes.patch
Applying: Fix Android WebAuth callback for system browser
.git/rebase-apply/patch:24: trailing whitespace.
.git/rebase-apply/patch:77: trailing whitespace.
}
warning: 2 lines add whitespace errors.
Using index info to reconstruct a base tree...
M src/Essentials/src/WebAuthenticator/WebAuthenticator.android.cs
M src/Essentials/src/WebAuthenticator/WebAuthenticator.shared.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Essentials/src/WebAuthenticator/WebAuthenticator.shared.cs
CONFLICT (content): Merge conflict in src/Essentials/src/WebAuthenticator/WebAuthenticator.shared.cs
Auto-merging src/Essentials/src/WebAuthenticator/WebAuthenticator.android.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix Android WebAuth callback for system browser
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128Please backport manually! |
Contributor
|
@hartez an error occurred while backporting to net7.0, please check the run log for details! Error: git am failed, most likely due to a merge conflict. |
hartez
added a commit
that referenced
this pull request
Jun 2, 2023
* Fix Android WebAuth callback for system browser This adds a flag to track if the web authentication flow was launched via custom tabs or the fallback, system browser. We were assuming it was always via custom tabs, and so the intermediate activity would be started which is not necessary or designed to compatible with the flow using the system browser. This changes the callback activity to properly route back to the intermediate activity for custom tabs initialized flows, and to just call the OnResume callback for other flows (system browser). * Auto-format source code --------- Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
PureWeen
pushed a commit
that referenced
this pull request
Jun 2, 2023
* Fix Android WebAuth callback for system browser This adds a flag to track if the web authentication flow was launched via custom tabs or the fallback, system browser. We were assuming it was always via custom tabs, and so the intermediate activity would be started which is not necessary or designed to compatible with the flow using the system browser. This changes the callback activity to properly route back to the intermediate activity for custom tabs initialized flows, and to just call the OnResume callback for other flows (system browser). * Auto-format source code --------- Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This was actually found somewhat by accident. On Android 11 (API30) and newer, you are required to declare in the manifest of your app intent queries if you want to be able to resolve intents from other packages than your own. The docs already describe this.
If you do not add the info to your manifest, the API will not resolve custom tabs and act as if your system does not support them. In this case we defer to using the system default browser (we just use a generic Action.VIEW + URI).
When this happens, and eventually the flow calls back to your callback activity, we were assuming that custom tabs were used and so we would route the callback to the intermediate activity (which is needed for custom tabs to clean up the custom tab - that's another story), but that callback would fail because we were missing bundle extras that are set only for custom tabs flows.
This PR adds some tracking state to know which type of flow we launched from so that the callback knows the appropriate action to take to complete the flow.
Issues Fixed