c# - 如何使用 Identity Server 4 撤销或使令牌无效?
问题描述
我读了这个文档:http ://docs.identityserver.io/en/release/endpoints/revocation.html
然后我试试这段代码:
AuthHelper.cs
public class AuthHelper
{
private string URL = "http://localhost:50847/connect/revocation";
public bool revocarToken(string token)
{
try
{
HttpClient client = new HttpClient();
string uri = URL;
StringContent contenido = new StringContent("token="+token+"&token_type_hint=access_token", System.Text.Encoding.UTF8, "application/x-www-form-urlencoded");
HttpResponseMessage response = client.PostAsync(uri, contenido).Result;
if (response.IsSuccessStatusCode)
return true;
return false;
}
catch (Exception ex)
{
throw;
}
}
}
但是,我得到这个错误:
我收到错误 400(错误请求)。提前致谢。
解决方案
您没有将所需的凭据发送到吊销端点。IdentityServer 希望您提供客户端 ID 和密码。请阅读https://www.rfc-editor.org/rfc/rfc7009#section-2.1规范以更好地理解。
我建议您使用IdentityModel2包来发出撤销请求(以及其他与 OIDC 相关的请求)。
推荐阅读
- java - 尝试转换列表时出错
列出 - vue.js - 如何检查 Vue.js 中的复选框?
- assembly - 缓冲区溢出函数地址被转义
- azure-ad-b2c - Azure Active Directory B2C - 应用服务 API 防火墙限制
- python - 根据具有爆炸和数组的条件复制行
- angular - Angular 4 Kendo 柱形图默认显示值并在底部显示 Y 轴名称
- c# - Entity Framework Core 3.0 使用 DbSet vs.DbQuery 和 FromSqlRaw 时的不同结果
- c++ - 带有参数 std::ofstream& 的 C++“错误:没有匹配的调用函数”
- scala - 映射集合并返回与输入相同类型的容器
- batch-file - 如何在 Camunda Cockpit 中批量删除失败的作业?