首页 新闻 会员 周边

asp net core oauth callback 404

0
悬赏园豆:10 [已解决问题] 解决于 2020-01-22 13:32

测试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相关的没找到相关的

wa3ha的主页 wa3ha | 初学一级 | 园豆:151
提问于:2020-01-17 15:01
< >
分享
最佳答案
0

我写错了。。。

app.UseAuthorization();---->app.UseAuthentication();

wa3ha | 初学一级 |园豆:151 | 2020-01-17 16:56
其他回答(1)
0
services.AddRouting();
收获园豆:10
Timetombs | 园豆:3954 (老鸟四级) | 2020-01-17 15:41

一样。。。

支持(0) 反对(0) wa3ha | 园豆:151 (初学一级) | 2020-01-17 16:07
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册