【问题标题】:How to revoke or invalidate token using Identity Server 4?如何使用 Identity Server 4 撤销或使令牌无效?
【发布时间】:2019-03-12 03:16:16
【问题描述】:

我阅读了这个文档: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(错误请求)。提前致谢。

【问题讨论】:

    标签: c# asp.net-core identityserver4


    【解决方案1】:

    您没有将所需的凭据发送到吊销端点。 IdentityServer 希望您提供客户端 ID 和密码。请阅读https://www.rfc-editor.org/rfc/rfc7009#section-2.1 规范以更好地理解。

    我建议您使用IdentityModel2 包来发出撤销请求(以及其他与 OIDC 相关的请求)。

    【讨论】:

    • 我收到类似的错误 invalid_client 对于吊销端点,但内省端点工作正常,有什么想法吗?
    猜你喜欢
    • 2018-06-01
    • 2021-07-28
    • 2015-05-06
    • 2017-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多