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