How to authenticate Facebook JWT in .Net Core API

Viewed 1265

I am in the process of creating a mobile app that allows users to log in via Facebook. Once logged in, the app holds on to a Bearer token used to make further requests. I am attempting to pass this token along to a C# .Net Core API. I'm attempting to write as little auth code as possible as doing it myself is prone to huge security issues.

Currently my code in Startup.cs looks like this:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {

    app.UseJwtBearerAuthentication(new JwtBearerOptions {
        AuthenticationScheme = "Bearer",        
    });

    app.UseFacebookAuthentication(new FacebookOptions {
        AppId = "****",
        AppSecret = "****",
        SignInScheme = "Bearer"
    });

    app.UseMvc();
}

With this, all requests return 401, even with a valid Bearer token. Now I'm not 100% sure UseJwtBearerAuthentication is even compatible with UseFacebookAuthentication, and if it is I'm sure I'm missing some code here. What steps should I take to get this working?

1 Answers
Related