.net-core - 身份模型是否具有密码资源所有者流程的令牌自动刷新?
问题描述
当使用RequestResourceOwnerPasswordAsync
a 的扩展时TokenClient
,给定带有 a 的响应,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;
}
解决方案
推荐阅读
- c - 如何在 mu C 项目中获取 GL 类型或确保浮点/双精度类型的位数?
- javascript - 更改未点击按钮的按钮不透明度
- linux-kernel - UBI 无法附加 mtd3
- javascript - 警告:道具类型失败:提供给“图像”的道具“来源”无效。我在对象中使用 require() 保存了图像的路径
- redis - 关机或重启时保持 Celery Queue
- unity3d - unity Frustum Culling with drawmesh 太早了
- python-3.x - Python:同时从两个 websocket 获取数据并处理它
- c++ - 为什么不能被 4 整除且宽度大于 32 像素的位图图像在创建像素数据数组时会导致错误的行扫描?
- authentication - Keycloak:有没有办法在使用“更新配置文件”所需的操作时使名字和姓氏不可编辑?
- r - 在R包`T-LoCoH`中计算s = 0时的时间重叠船体