How to authenticate Facebook JWT to .Net Core API

I am creating a mobile application that allows users to register via Facebook. After entering the system, the application is held on the carrier token used for subsequent requests. I am trying to pass this token along with the C # .Net Core API. I am trying to write as little authorization code as possible because it is subject to huge security issues.

Currently, my code in is Startup.csas follows:

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();
}

However, all requests return 401, even with a valid carrier token. Now I'm not 100% sure UseJwtBearerAuthenticationeven compatible with UseFacebookAuthentication, and if so, I'm sure that the code is missing here. What steps should I take to get this to work?

+6
1

, . , googling, (?) . Facebook, Facebook . :

  • , API Facebook ( ).
  • ExternalLoginSignInAsync SignInManager<User>: var result = await _signInManager.ExternalLoginSignInAsync(provider, userId, isPersistent: false);, userId Facebook.
  • result.Succeeded is false:
    • Facebook https://graph.facebook.com/{userId}
    • .
    • await _userManager.AddLoginAsync(user, userLoginInfo);, userLoginInfo provider (Facebook), userId ( Facebook) application ( )
    • await _signInManager.SignInAsync(user, false);

, _userManager.FindByIdAsync(userId);

API , Authorization header

0

All Articles