Google OpenAuth回程票-但netcore尚未登录

时间:2018-11-20 19:57:44

标签: asp.net-core oauth-2.0 asp.net-identity google-oauth2

我使用netcore2.1通过Google登录,尽管返回了票证,但是每次我访问需要[authorize]的页面时,它仍然会将我重定向到登录页面,而不是我请求的页面

我正在使用我的登录名,然后正确的claims回来了。

services.AddAuthentication().AddGoogle(options =>
            {

                options.ClientId = Configuration["Authentication:Google:ClientId"];
                options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
                options.Backchannel = new HttpClient(httpClientHandler);
                // Provide the Google Client 
                options.Scope.Add("https://www.googleapis.com/auth/plus.login");
                options.SaveTokens = true;
                options.Events.OnCreatingTicket = ctx =>
                {
                    List<AuthenticationToken> tokens = ctx.Properties.GetTokens()
                        as List<AuthenticationToken>;
                    tokens.Add(new AuthenticationToken()
                    {
                        Name = "TicketCreated",
                        Value = DateTime.UtcNow.ToString()
                    });
                    ctx.Properties.StoreTokens(tokens);
                    return Task.CompletedTask;
                };
            });

我认为我缺少什么?

0 个答案:

没有答案