Essentials
Essentials copied to clipboard
[Bug/Question][Android] Web Authenticator does not redirect back to app when doing Google Auth on certain browsers
Description
Hello team, I came across this interesting behaviour and I'm not quite sure it is a Bug with Xamarin Essentials, given that it is not 100% consistent, so here goes to the description of it.
I started using the Web Authenticator to do social media auth for an app, but I bumped into an issue, when performing the auth on Android apps, with Google authentication, where in some browsers after the user performs the login to google, the browser does not close and redirects the user back to the app.
At first, I thought it was an issue with my Intent Callback Data Scheme as described in this issue. However, after testing in multiple Android Emulators and Devices I noticed that the problem only happens in certain browsers, whereas in other browsers it will work just fine.
This is also interesting because it is only happening when I try with Google oAuth, the Facebook oAuth that I have setup works every time.
The two browsers that I can say for sure that are not working are:
Phone/OS: Samsung S7, Android Version 9.0 Browser: Samsung Internet Version: 7.0.10.47
Android Emulator, Android version 9.0 Browser: Google Chrome Version: 69.0.3497.100
One Browser that I can confirm that works is:
Phone/OS: Samsung S7, Android Version 9.0 Browser: Google Chrome Version: 76.0.3809.111
Steps to Reproduce
- Follow the first steps of setting up Web Authenticator for Android in this tutorial
- Follow the google guide on how to setup oAuth.
- Test it by calling
await WebAuthenticator.AuthenticateAsync - Perform the login with a google account.
Expected Behavior
After performing the login on the google account, independently of the browser being used, the user should be redirected back to the app.
Actual Behavior
If the default Browser on the phone is one of the two mentioned above in the description, the browser will be redirected to google.com home page.
Basic Information
- Version with issue: 1.6.1
- Last known good version: ???
- IDE: Jet Brains Rider
- Platform Target Frameworks:
- Android: 9.0
- Android Support Library Version: Xamarin.Android.Support.v4 v:28.0.0.3
- Nuget Packages: https://www.nuget.org/packages/Xamarin.Essentials/1.6.1
- Affected Devices: Android Devices that have the above-described browser versions.
I also face this issue @DanielCauser but I have issue only on iOS 12 (iPhone 6). It's also with apple auth.
I got the same issue @DanielCauser did you manage to work around it ?
Hey, I did not find a solution to this, since I could only reproduce it in a few scenarios, where updating the browser on the phone would fix the problem, this issue was not truly a show stoper.
Hey there, just to point out this issue is still present. I tried for a few hours to getting right using an emulator without Google apps (browser was Webview tester), once I switched to a Pixel emulator with Chrome installed it worked, but it'd be nice to support all browsers. MSAL plugin doesn't have this issue
Having the same problem on an emulator running Android 8.1, though our physical device also running 8.1 doesn't.
Any news? Having the same problem on an emulator running Android 12 and WebView browser, also on a physical device RedmiNote 7 Pro. Xamarin.Essentials 1.7.3, Xamarin.Forms 5.0.0.2515
Same issue in .Net Maui. The Android app is targeting net6.0-Android31. The minimum target is net6.0-Android30. My test device is an Android emulator running API 31. I'm running Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.3.6 with Xamarin.Android.SDK version 13.0.0.0.
Looks like the same here
same issue here using Android emulator and physical pixel 7 pro using .net maui & blazor hybrid based on .net 8.
Do we have any solution for this. Just checking if we got anything.