C# 具有ASP.NET Core 2.0的Github OAuth提供程序不起作用

C# 具有ASP.NET Core 2.0的Github OAuth提供程序不起作用,c#,github,asp.net-core,oauth-2.0,asp.net-core-2.0,C#,Github,Asp.net Core,Oauth 2.0,Asp.net Core 2.0,我已尝试在ASP.NET Core 2.0中将Github设置为外部提供程序,如下所示: services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddOAuth("Github", "Git Hub", gitHubOptions => { gitHubOpt

我已尝试在ASP.NET Core 2.0中将Github设置为外部提供程序,如下所示:

services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
            .AddCookie()
            .AddOAuth("Github", "Git Hub", gitHubOptions =>
            {
                gitHubOptions.ClientId = Configuration["Auth:Github:ClientId"];
                gitHubOptions.ClientSecret = Configuration["Auth:Github:ClientSecret"];
                gitHubOptions.CallbackPath = new PathString("/signin-github");
                gitHubOptions.AuthorizationEndpoint = "http://github.com/login/oauth/authorize";
                gitHubOptions.TokenEndpoint = "https://github.com/login/oauth/access_token";
            })
我还设置了一个带有重定向url的Github应用程序

externel provider(Github)按钮显示在登录页面上。按下按钮时,也会显示Github登录页面。输入凭据并按“授权”后,用户将重定向到“我的服务”的登录页面,但无法注册

同样的情况也适用于微软、谷歌和Facebook。“注册”页面会显示一个电子邮件地址,用户可以注册


你知道吗?

好奇的是,这里缺少的元素是将用户信息映射到声明。这是链接样本的摘录。


请看这里的示例@Tratcher,thx它非常有效帮助我:D
o.ClientId = Configuration["github:clientid"];
o.ClientSecret = Configuration["github:clientsecret"];
o.CallbackPath = new PathString("/signin-github");
o.AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
o.TokenEndpoint = "https://github.com/login/oauth/access_token";
o.UserInformationEndpoint = "https://api.github.com/user";
// Retrieving user information is unique to each provider.
o.ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "id");
o.ClaimActions.MapJsonKey(ClaimTypes.Name, "login");
o.ClaimActions.MapJsonKey("urn:github:name", "name");
o.ClaimActions.MapJsonKey(ClaimTypes.Email, "email", ClaimValueTypes.Email);
o.ClaimActions.MapJsonKey("urn:github:url", "url");