第6章 令牌撤销端点(Token Revocation Endpoint) - IdentityModel 中文文档(v1.0.0)

OAuth 2.0令牌撤销的客户端库是作为扩展方法提供的HttpClient。

以下代码撤消撤销端点处的访问令牌令牌:

var client = new HttpClient();

var result = await client.RevokeTokenAsync(new TokenRevocationRequest
{
    Address = "https://demo.identityserver.io/connect/revocation",
    ClientId = "client",
    ClientSecret = "secret",

    Token = accessToken
});

响应属于TokenRevocationResponse类型使您可以访问原始响应以及解析的JSON文档(通过RawJson属性)。

在使用响应之前,您应该始终检查IsError属性以确保请求成功:

if (response.IsError) throw new Exception(response.Error);

github地址

posted @ 2019-04-28 23:08  ThinkJay  阅读(1191)  评论(0编辑  收藏  举报