我一直试图将AWS Cognito作为外部提供程序添加到我的IdentityServer4实例中。
services.AddAuthentication().AddOpenIdConnect(options =>
{
options.Authority = "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_ydUErvZQJ/";
options.ClientId = "2m50t6m94ec7pcnuk4179k15sf";
options.ResponseType = OpenIdConnectResponseType.Token;
options.Scope.Add("email");
options.Scope.Add("profile");
options.Scope.Add("openid");
options.Scope.Add("aws.cognito.signin.user.admin");
});
不幸的是,我收到一条错误消息,消息为空。我确定我在配置中丢失了一些东西。我已经查阅了AWS Cognito和IdentityServer4文档,但似乎看不到缺少的内容。
System.Exception: An error was encountered while handling the remote login.
---> System.Exception: OpenIdConnectAuthenticationHandler: message.State is null or empty.
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
at IdentityServer4.Hosting.FederatedSignOut.AuthenticationRequestHandlerWrapper.HandleRequestAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)