【发布时间】:2017-04-24 07:44:52
【问题描述】:
我正在尝试使用 IdentityServer3,但不知道为什么我总是收到“invalid_client”错误,无论我做什么。
这是我正在使用的代码:
//Startup.cs (Auth c# project)
public void Configuration(IAppBuilder app) {
var inMemoryManager = new InMemoryManager();
var factory = new IdentityServerServiceFactory()
.UseInMemoryClients(inMemoryManager.GetClients())
.UseInMemoryScopes(inMemoryManager.GetScopes())
.UseInMemoryUsers(inMemoryManager.GetUsers());
var options = new IdentityServerOptions {
Factory = factory,
RequireSsl = false
};
app.UseIdentityServer(options);
}
InMemoryManager 助手。
//InMemoryManager.cs
public class InMemoryManager {
public List<InMemoryUser> GetUsers() {
return new List<InMemoryUser> {
new InMemoryUser {
Username = "alice",
Password = "password",
Subject = "2",
Claims = new [] {
new Claim("User name", "Alice")
}
}
};
}
public IEnumerable<Scope> GetScopes() {
return new[] {
new Scope {
Name = "api1",
DisplayName = "API 1"
}
};
}
public IEnumerable<Client> GetClients() {
return new[] {
new Client {
ClientName = "Silicon on behalf of Carbon Client",
ClientId = "carbon",
Enabled = true,
//AccessTokenType = AccessTokenType.Reference,
Flow = Flows.ResourceOwner,
ClientSecrets = new List<Secret> {
new Secret("secret".Sha256())
},
AllowedScopes = new List<string> {
"api1"
}
}
};
}
}
这是我一直得到的结果。
我正在使用邮递员来尝试身份验证服务器,但我总是收到该错误。我已经阅读了其他解决方案,但似乎没有一个可行,我不知道还有什么可以尝试的。
干杯。
【问题讨论】:
-
前一周我遇到了这个错误的问题,但我们使用的是授权码授权,它与重定向 URI 有关 - 你能在日志中看到任何内容吗?
-
您是否启用并检查了日志?他们提供了很多信息
-
你使用的是什么流量。它是资源所有者吗?
-
与往常一样,启用日志记录以确定问题所在。
-
@arosgab 您能否发布一个回答您自己的问题的答案,显示 IdentityServer 配置和邮递员的请求详细信息?就像您提出答案一样,但现在使用正确的配置,以便在没有 invalid_client 错误的情况下发出请求。
标签: c# oauth-2.0 postman identityserver3 openid-connect