使用ASP.NET Core的OpenId + Jwt承载:签名无效

时间:2017-04-17 18:22:03

标签: asp.net-core jwt openid google-openid asp.net-core-webapi

我试图在我的asp.net核心项目中将openid与JWT Bearer中间件集成。

这是我的启动代码:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseCors(builder => builder.AllowAnyOrigin()
                .AllowCredentials()
                .AllowAnyMethod()
                .AllowAnyHeader());

            app.UseJwtBearerAuthentication(new JwtBearerOptions()
            {
                AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme,
                AutomaticAuthenticate = true
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            {
                ClientId = "<my-client-id>",
                ClientSecret = "<my-client-secret>",
                Authority = "https://accounts.google.com",
                ResponseType = OpenIdConnectResponseType.Code,
                GetClaimsFromUserInfoEndpoint = true,
                CallbackPath = "/api/home/redirect",
                Scope = { "email", "openid", "profile"},
                SignInScheme = JwtBearerDefaults.AuthenticationScheme
            });


            app.UseMvc();
        }

当我向api / home发送请求时(此请求需要身份验证),它会向我发出错误响应:

WWW-Authenticate→Bearer error =&#34; invalid_token&#34;,error_description =&#34;签名无效&#34;

我错过了什么。 有人可以帮我吗?

谢谢。

0 个答案:

没有答案