刷新 token 后,Azure AD B2C 访问 token 声明不会更新

标签 azure active-directory azure-active-directory azure-ad-b2c azure-ad-graph-api

我们在应用程序中使用 Azure AD B2C。 我们授权用户使用API​​

https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/authorize?client_id=<client-id-uuid>
&nonce=defaultNonce&redirect_uri=http%3A%2F%2Flocalhost%3A4200%2Findex.html
&scope=openid%20offline_access%20https%3A%2F%2F{tenant}.onmicrosoft.com%2F<client-id-uuid>%2FUser.all
&response_type=code&prompt=login

使用上面我们获取授权码。

此身份验证代码用于通过应用程序对用户进行身份验证,并使用

获取 access_tokenrefresh_tokenid_token
POST /{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/token HTTP/1.1
Host: {tenant}.b2clogin.com
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache

grant_type=authorization_code&code={auth code received in previous step}
&scope=openid%20offline_access%20https%3A%2F%2F{tenant}.onmicrosoft.com%2F<client-id-uuid>%2FUser.all
&client_id={client id}&redirect_uri=localhost%253A4200%252Flogin.html%3A

身份验证后,代码用于访问各种端点和 azure 功能。 在这个过程中,我们需要用户属性,例如电子邮件、显示名称、国家/地区等用户在注册时输入的信息。 除了默认属性之外,我们还有一些自定义属性,例如特定于我们的 Web 应用程序用例的 team_name。这些属性随着时间的推移而变化。

例如:人可以切换团队。因此我们使用 Graph API 在用户属性中修改它。 因此,在这种情况下,如果属性 team_name = 'Team ABC' 现在更改为 team_name = 'Team XYZ'

但属性更改后,属性不会反射(reflect) access_token/refresh_tokenid_token 中的新值。有没有一种方法可以在不重新授权用户的情况下获取 token 中刷新的值?

目前,我们从 Graph API 获取用户属性,但如果我们在 token 中获取刷新的值,它会更快、更方便。

最佳答案

自定义策略没有公开记录的机制来在刷新 token 流中获取新的访问 token 声明。所以你所观察到的结果是预期的

关于刷新 token 后,Azure AD B2C 访问 token 声明不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63392633/

相关文章:

azure - Azure B2C 用户登录流程期间出现 Apple 错误 "Invalid web redirect url."

iis - Azure 网站上的 URL 重写到另一台服务器

azure - 为什么 NuGet 恢复任务必须与构建任务位于同一作业中?

azure - 无法在 CreateQuery 上获取 Azure TableEntity etag

c# - DirectoryServices.Protocols.SearchRequest 返回 GUID 的多个结果

azure-active-directory - 基于 token 和基于 cookie 的应用程序之间的 SSO 体验

Azure kubernetes - Prometheus 处理多个应用程序

c# - Active Directory PrincipalContext.ValidateCredentials 域消歧

ubuntu - samba 检索具有任意属性的用户

azure - vscode azure 应用程序配置 403 禁止