Closed sunco007 closed 2 years ago
I also facing the same issue. did you found the solution ? @sunco007
I also facing the same issue. did you found the solution ? @sunco007
Yes and no. Unfortunately my issue has nothing to do with Webauthenticator (I guess)
My problem deep down is how my provider Piano.io/Tinypass handle the Facebook answer
This flow works fine if I run it from desktop/mobile browser but fails with webview or app opening external browser
I debug the flow steps and the last redirect in fact fails, does not redirect because some javascript errors.. don't know if is how Webauthenticator opens the external browser (e.g. no javascript enabled), something about cookies, something about limited version of external browser
I dowloaded this code https://github.com/brminnick/WebAuthenticatorRepro and according to this post https://github.com/xamarin/Essentials/issues/1298 I fixed the code
Then I modify the code to make a call to Facebook and then to my backend and now directly to my app, it works fine
I mean, removing the Piano.io/Tinypass part, works
Description
I'm working with a new clean app to use the WebAuthenticator. This may work with an external backend in Php
I already read this, this and this but still the same error: TaskCanceledException: A task was canceled
System.Threading.Tasks.TaskCanceledException: A task was canceled. at Xamarin.Essentials.WebAuthenticator.PlatformAuthenticateAsync (Xamarin.Essentials.WebAuthenticatorOptions webAuthenticatorOptions) [0x001e7] in D:\a\1\s\Xamarin.Essentials\WebAuthenticator\WebAuthenticator.android.cs:96 at LoginSocialPiano.MainPage.webView_Navigated (System.Object sender, Xamarin.Forms.WebNavigatedEventArgs e) [0x0014e] in C:\Users\XXXX\source\repos\XXXX\LoginSocialPiano\MainPage.xaml.cs:63
The line 63 is just this: authResult = await WebAuthenticator.AuthenticateAsync(new Uri(datos), new Uri("xamarinessentials://"));
This is the flow the app uses
If you follow the flow in desktop, it works. Of course, it fails at the end because the DataScheme is not there. The url in the app is just temporal, will change when all works
1- App connects via webview to backend to retrieve a Facebook url, something like this:
https://www.facebook.com/v2.6/dialog/oauth?display=popup&response_type=code&client_id=XXXX&redirect_uri=https%3A%2F%2Fid.tinypass.com%2Fid%2Fapi%2Fv1%2Fidentity%2Flogin%2Fsocial%2Fcallback&scope=email&state=XXXX
2- App then connects via WebAuthenticator to that url
3- User interact and logged in
4- Facebook redirects to my provider (tinypass, piano.io)
5- The provider then calls my backend
6- The backend does some curl stuff
7- Backend redirects to the callback
This are 4 answers tried in the backend
header("location: xamarinessentials://#access_token=123", true, 302); header("location: xamarinessentials://#access_token=123"); header("location: xamarinessentials://"); header("location: xamarinessentials://, true, 302);
Expected Behavior
Return to the app and get the parameters
Actual Behavior
Returns to the app and then says there is an error
Basic Information
NETStandard.Library: 2.0.3 Xamarin.Essentials: 1.7.2 Xamarin.Forms: 5.0.0.2401 Visual Studio: 2022 - 17.1.4 Android: Real device - LG-X210 with Chrome 95.0.4638.74 Android SDK: 31.0.3 Target: 12.0 S (API 31) Min ver: 5.0 API 21
Reproduction Link
https://1drv.ms/u/s!AjVtN9vWQzh3nfAn0Nvyqgsu4AzAkw?e=P205vJ
When working, will clean and shrink the code. For now, I just want to make it work