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