我有一个运行在ASP.NET MVC 4.5.2上的网站。我有一个IdentityServer4服务器正在运行,但是当我尝试对它进行身份验证时,我得到了一个:
invalid_request对于ASP.NET Core,文档有:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = "oidc",
SignInScheme = "Cookies",
Authority = "http://localhost:5000",
RequireHttpsMetadata = false,
ClientId = "mvc",
SaveTokens = true
});我在我的项目NuGet中包含了下面的Microsoft.Owin.Security.OpenIdConnect包。我的代码如下:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
AuthenticationType = "oidc",
SignInAsAuthenticationType = "Cookies",
Authority = "http://localhost:5000",
ClientId = "mvc",
});如何正确地连接到它呢?
发布于 2016-09-29 13:15:10
好的,我开始工作了。
您需要向解决方案Microsoft.Owin.Security.OpenIdConnect中添加以下NuGet包。
我的Startup.Auth.cs包含
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Authority = "http://localhost:5000", //ID Server
ClientId = "demo",
ResponseType = "id_token code",
SignInAsAuthenticationType = "Cookies",
RedirectUri = "http://localhost:51048/signin-oidc", //URL of website
Scope = "openid",
});
}我在IdentityServer中的客户端配置是:
public static IEnumerable<Client> GetClients()
{
return new List<Client> {
new Client {
ClientId = "demo",
AllowedScopes = new List<string> { "openid"},
AllowedGrantTypes = GrantTypes.Hybrid,
RedirectUris = new List<string>{"http://localhost:51048/signin-oidc"},
}
};
}https://stackoverflow.com/questions/39642715
复制相似问题