/// <summary> /// 返回一个携带新令牌的资源访问客户端对象。 /// </summary> /// <param name="token"></param> /// <returns></returns> public HttpClient GetResourceClient(TokenResponse token) { this.CurrentToken = token; SetAuthorizationRequest(this.ResourceServerClient, token); return(this.ResourceServerClient); }
public void SetAuthorizationRequest(HttpClient httpClient, TokenResponse token) { httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.AccessToken); }
/// <summary> /// 使用指定的令牌,直接刷新访问令牌 /// </summary> /// <param name="token"></param> /// <returns></returns> public TokenResponse RefreshToken(TokenResponse token) { this.CurrentToken = token; return(GetToken("refresh_token", token.RefreshToken).Result); }