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文档(经过Raw
和Json
属性)。c#
在使用响应以前,您应该始终检查IsError
属性以确保请求成功:ide
if (response.IsError) throw new Exception(response.Error);
github地址code