azure - Microsoft.Identity.Web 库为带有 Azure Cosmos DB 的 ASP.NET Core 应用程序分布式令牌缓存。我们如何重用缓存的令牌?
问题描述
我从以下网站进行了实施:
我已经使用这个 NuGet 包来存储令牌:Microsoft.Extensions.Caching.Cosmos
在 startup.cs 文件中添加代码
services.AddCosmosCache((CosmosCacheOptions cacheOptions) =>
{
cacheOptions.ContainerName = Configuration["CosmosCacheContainer"];
cacheOptions.DatabaseName = Configuration["CosmosCacheDatabase"];
cacheOptions.ClientBuilder = new CosmosClientBuilder(Configuration["CosmosConnectionString"]);
cacheOptions.CreateIfNotExists = true;
});
services.AddMicrosoftWebAppAuthentication(Configuration)
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { "User.Read", "Mail.Read" })
.AddDistributedTokenCaches();
令牌成功保存在 cosmos DB 中。
现在我有两个问题:
如何使用此库 Microsoft.Identity.Web 扩展方法获取已存储的令牌?
令牌到期后如何更新,我们是否需要执行任何额外的活动?
解决方案
推荐阅读
- python - AttributeError at / 'OrderedDict' object has no attribute 'register' in Django REST framework from quickstart documentation
- python - 如何检测和跟踪视频中的阴影
- css - Kartik fileInput CSS 覆盖其他样式表
- javascript - 通过jquery将用户输入文本框值从部分页面发送到控制器
- python - 使用glom将字典列表的字段提取到新字典中
- android - 无法在 intellij idea 的设计选项卡中看到视图
- wordpress - Firefox 未加载网站样式表和控制台显示“源地图错误:请求失败,状态为 404”
- java - 在使用 java Spring 的 post 方法中使用一个 RequestBody 来区分 xml
- android - Android USB 库中的 hid_get_feature_report 模拟
- angular - 如何使用角度获取当前索引中继器