在将RequestResourceOwnerPasswordAsync
扩展用于TokenClient
时,给定响应为refresh_token
和expires_in
的情况下,是否存在令牌高速缓存的默认内存内插值?
access_token
期满(从缓存自动退出)后,令牌客户端可以使用刷新令牌来请求令牌。
还是我们必须推出自己的产品?
private async Task<string> GetToken(
string clientId, string clientSecret, string username, string password)
{
string tokenAddress = "https://api.example.com/oauth2/token";
var tokenClient = new TokenClient(tokenAddress, clientId, clientSecret);
var result = await tokenClient.RequestResourceOwnerPasswordAsync(username, password);
// do we create a wrapper around the token client that will implement a cache and auto-refresh
// so that the next call, with same arguments will return same result.AccessToken
// if still within bounds of the TimeNow.AddSeconds(result.ExpiresIn) window
return result.AccessToken;
}