测试OAuth。。。在2.x上都是正常的,在3.x上不正确,代码如下
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddAuthentication()
.AddCookie()
.AddOAuth("GitHub", options =>
{
.....
options.CallbackPath = new PathString("/signin-github");
options.AuthorizationEndpoint = "https://github.com/login/oauth/authorize";
options.TokenEndpoint = "https://github.com/login/oauth/access_token";
options.UserInformationEndpoint = "https://api.github.com/user";
options.Events = new OAuthEvents
{
OnCreatingTicket = async context =>
{
........
}
};
});
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
认证成功之后回调的地址404.。。看了半天Endpoint相关的没找到相关的
我写错了。。。
app.UseAuthorization();---->app.UseAuthentication();
services.AddRouting();
一样。。。