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

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

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

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属性)。c#

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

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

github地址code

相关文章
相关标签/搜索