【发布时间】:2021-09-24 21:57:42
【问题描述】:
我在将自定义声明(租户 ID)添加到我的令牌时遇到问题。所以我的程序允许用户使用租户 ID 切换他们的工作区。为此,我需要接收选定的租户 ID 并在令牌中生成带有所选租户 ID 的新令牌。
为了在登录时第一次生成令牌,我使用了这段代码
var tokenResponse = await httpclient.RequestPasswordTokenAsync(new PasswordTokenRequest
{
Address = discoveryDocument.TokenEndpoint,
UserName = model.PhoneNumber,
Password = model.Password,
ClientId = Configuration["ClientInformation:ClientId"],
ClientSecret = Configuration["ClientInformation:ClientSecret"]
});
为了在他们登录切换租户后生成新令牌,我使用了刷新令牌。
var tokenResponse = await httpclient.RequestRefreshTokenAsync(new RefreshTokenRequest
{
Address = discoveryDocument.TokenEndpoint,
ClientId = Configuration["ClientInformation:ClientId"],
ClientSecret = Configuration["ClientInformation:ClientSecret"],
RefreshToken = model.RefreshToken
});
我已经看到配置文件服务如何使用 claimprincipal 接收数据,这就是我对如何在 claimprincipal 中插入新值感到困惑的地方
所以我的问题是如何将选定的租户 ID 发送到配置文件服务?
【问题讨论】:
标签: c# asp.net .net jwt identityserver4