-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Android WebAuth callback for system browser flows #15187
Fix Android WebAuth callback for system browser flows #15187
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).
Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines. |
* 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>
/backport to net7.0 |
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/5138834817 |
@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 128 Please backport manually! |
@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. |
* 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>
* 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>
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