Setting Up LinkedIn/OAuth Authentication in ASP.NET Core 2.0

匆匆过客 提交于 2019-11-30 15:24:00

You mixed up the authentication scheme associated with your custom LinkedIn handler registration with the sign-in scheme that OAuthHandler will ultimately call to persist the identity (typically a cookie handler instance).

Fix your registration to specify LinkedIn as the scheme and social_login as the sign-in scheme (assuming your cookie handler is indeed named social_login), and it should work:

services.AddAuthentication()
    .AddCookie("social_login")
    .AddOAuth("LinkedIn", options =>
    {
        options.SignInScheme = "social_login";

        // ...
    });

Note: you can remove the SignInScheme assignation if social_login is the default sign-in scheme (i.e if you call services.AddAuthentication("social_login") or services.AddAuthentication(options => options.DefaultSignInScheme = "social_login"):

services.AddAuthentication("social_login")
    .AddCookie("social_login")
    .AddOAuth("LinkedIn", options =>
    {
        // ...
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!