【发布时间】:2015-09-08 05:31:09
【问题描述】:
new Client
{
ClientId = "esmifavorito",
ClientName = "esmifavorito-client",
Enabled = true,
ClientSecrets = new List<ClientSecret>
{
new ClientSecret("esmifavorito".Sha256()) //PQ/pIgjXnBfK67kOxGxz9Eykft6CKPkPewR3jUNEkZo=
},
Flow = Flows.ResourceOwner,
//RequireConsent = false,
//AllowRememberConsent = false,
//ClientUri = "http",
RedirectUris = new List<string>
{
"https://localhost:44304",
},
ScopeRestrictions = new List<string>
{
},
AllowedCorsOrigins = new List<string>
{
"https://localhost:44304",
"http://localhost:50655",
"chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm",
"*",
},
PostLogoutRedirectUris = new List<string>
{
"https://localhost:44304",
},
AccessTokenType = AccessTokenType.Jwt,
IdentityTokenLifetime = 3000,
AccessTokenLifetime = 3600,
AuthorizationCodeLifetime = 300
}
我已经注册了我的客户,它可以通过隐式流程工作,但我需要实现一个登录表单,所以我正在尝试授予资源所有者密码凭据。 我正在使用 Chrome 中的 Postman 向端点发出请求(这就是为什么我将 chrome-extension 添加到 CORS,只是为了看看这是否是错误......)
我尝试了很多请求(使用 https)
POST /connect/token HTTP/1.1
Host: localhost:44302
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=test&password=testuser&client_id=esmifavorito
-
POST /connect/token HTTP/1.1
Host: localhost:44302
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=test&password=testuser&client_id=esmifavorito&client_secret=PQ%2FpIgjXnBfK67kOxGxz9Eykft6CKPkPewR3jUNEkZo%3D
-
POST /connect/token HTTP/1.1
Host: localhost:44302
Authorization: Basic ZXNtaWZhdm9yaXRvOlBRL3BJZ2pYbkJmSzY3a094R3h6OUV5a2Z0NkNLUGtQZXdSM2pVTkVrWm89
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=test&password=testuser
那些应该有效,但我总是得到 invalid_client
错误日志是空的,不知道是否做了tracer注册对
LogProvider.SetCurrentLogProvider(new DiagnosticsTraceLogProvider());
app.UseIdentityServer(new IdentityServerOptions
{
LoggingOptions = new LoggingOptions {
IncludeSensitiveDataInLogs = true,
WebApiDiagnosticsIsVerbose = true,
EnableWebApiDiagnostics = true,
//EnableHttpLogging = true
},
SiteName = "Thinktecture IdentityServer3 - UserService-AspNetIdentity",
SigningCertificate = Certificate.Get(string.Format(@"{0}\bin\IdentityServer\IdentityServerEMFDev.pfx", AppDomain.CurrentDomain.BaseDirectory), "KG0yM0At"),
Factory = idSvrFactory,
CorsPolicy = CorsPolicy.AllowAll,
AuthenticationOptions = new AuthenticationOptions
{
IdentityProviders = ConfigureAdditionalIdentityProviders,
},
}
);
在 web.config 中有这个
<trace autoflush="true"
indentsize="4">
<listeners>
<add name="myListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="Trace.log" />
<remove name="Default" />
</listeners>
</trace>
客户端数据正确,因为我已成功使用隐式流程登录。 我错过了什么?这让我很紧张,我正在阅读 OAuth RFC,但我不明白为什么这不起作用。
【问题讨论】:
-
我忘记添加范围参数了,但是在过去的请求中我使用了它,结果是一样的。
标签: asp.net oauth-2.0 openid identityserver3