Use native app for Facebook login using ASP.NET Identity or Identity Server 4

Viewed 206

I am trying to add external auth to my ASP.NET Core application. I have tried with both identity server 4 and asp.net identity using a blazor server app but when using the site in the mobile app, it takes to facebook.com login page. Is there a way to trigger the Facebook app for login?

I am planning to use this to register a user within a Xamarin app by using my website inside a webview.

I have this default code in both identity server 4 and blazor app to show Facebook login button:

services.AddAuthentication().AddFacebook(facebookOptions =>
{
    facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
    facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];

    facebookOptions.Events = new OAuthEvents()
    {
        OnRemoteFailure = loginFailureHandler =>
        {
            var authProperties = facebookOptions.StateDataFormat.Unprotect(loginFailureHandler.Request.Query["state"]);
            loginFailureHandler.Response.Redirect("/Identity/Account/Login");
            loginFailureHandler.HandleResponse();
            return Task.FromResult(0);
        }
    };
});

Is there any option I need to set in my above code?

0 Answers
Related