我无法让 IdentityModel 验证令牌是否仍有有效会话。这是我的客户代码。_http
是 的一个实例HttpClient
。
不要在这种情况下判断我使用用户名/密码。它是一个受信任的应用程序,我首先从更简单的场景开始,然后计划继续使用混合模型。
var discovery ??= await _http.GetDiscoveryDocumentAsync("http://localhost:5000");
var response = await _http.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = discovery.TokenEndpoint,
ClientId = ClientId,
ClientSecret = ClientSecret,
Scope = "api1",
UserName = "test",
Password = "test"
}); // This succeeds while returning an AccessToken
var introspectionResponse = await _http.IntrospectTokenAsync(new TokenIntrospectionRequest
{
Address = discovery.IntrospectionEndpoint,
ClientId = ClientId,
ClientSecret = ClientSecret,
Token = response.AccessToken
}); // This fails with an unauthenticated error