Forum Libraries, Components, and Plugins

Xamarin Essentials - Authentication with Facebook - Android

Federico787878Federico787878 USMember ✭✭

Good morning

my aim is to integrate facebook authentication with my mobile application that i made with xamarin form.

For this purpose I followed this procedure:

The web api part, on the other hand, is made using NET Core 3.

I created my application from

At first I had problems with the lack of domain.

I was accessing the web api directly via the ip address and without https and this gave me problems.

Now I have fixed these problems but it is not clear how the return callback should be handled.

I did as written in the documentation

 var callbackUrl = new Uri ("myapp://");
 r = await WebAuthenticator.AuthenticateAsync (authUrl, callbackUrl);

Actually this callBackurl is IGNORED and the url that is called is the default callback url which is:

This page is not present in my web api project and therefore it all ends with a sad 404 error.

in the example it is not clear if a signin-facebook control should be created.

I would have expected the callback to call my app again and have permission to read the necessary user information.

async Task OnAuthenticate(string scheme)
        WebAuthenticatorResult r = null;

        if (scheme.Equals("Apple")
            && DeviceInfo.Platform == DevicePlatform.iOS
            && DeviceInfo.Version.Major >= 13)
            r = await AppleSignInAuthenticator.AuthenticateAsync();
            var authUrl = new Uri(authenticationUrl + scheme);
            var callbackUrl = new Uri("myapp://");

            r = await WebAuthenticator.AuthenticateAsync(authUrl, callbackUrl);

        AuthToken = r?.AccessToken ?? r?.IdToken;
    catch (Exception ex)
        AuthToken = string.Empty;
        await DisplayAlertAsync($"Failed: {ex.Message}");
Sign In or Register to comment.