【发布时间】:2022-01-09 09:33:47
【问题描述】:
使用基本登录用户流策略。 acquireTokenSilent 的响应在我的开发环境中与我的 QA 环境不同,即使代码相同(已升级)并且 ADB2C 中的配置相同。我注意到的主要区别是我没有收到来自 AuthenticationResult 响应对象的 expiresOn 属性。
我可以看到SessionStorage 中的idTokenClaims 也略有不同。开发环境有一个at_hash 属性,而QA 没有。
响应对象有什么不同吗?
我检查了所有设置,但两个环境上的“令牌生命周期设置”是相同的:
Access & ID token lifetimes (minutes): 60
Refresh token lifetime (days): 14
Refresh token sliding window lifetime: Bounded
Lifetime length (days): 90
检查QA 上/token 端点的网络响应我收到了这个:
client_info: "ey..."
id_token: "ey..."
not_before: 1638467851
refresh_token: "ey..."
refresh_token_expires_in: 86398
scope: ""
token_type: "Bearer"
检查DEV 上/token 端点的网络响应我收到了这个:
access_token: "ey.."
client_info: "ey.."
expires_in: 3600
expires_on: 1638485366
id_token: "ey.."
not_before: 1638481766
refresh_token: "ey.."
refresh_token_expires_in: 86400
resource: "xxxxxx"
scope: "https://xxxxxx.onmicrosoft.com/demo-api/demo.all.all"
token_type: "Bearer"
一些相关代码:
import { PublicClientApplication } from '@azure/msal-browser'
import { useMsal } from '@azure/msal-react'
const msalInstance = new PublicClientApplication(msalConfig)
...
const { instance, accounts, inProgress } = useMsal()
useEffect(() => {
if (account) {
instance
.acquireTokenSilent({
scopes: myloginScopes,
account
})
.then(res => {
if (res) {
console.log(res.expiresOn) // <-- exists on one environment and not the other
}
})
}
}, [account, instance, inProgress])
开发环境信息:
Azure ADB2C
@azure/msal-browser 2.17.0
@azure/msal-react: 1.0.2
【问题讨论】:
标签: azure-ad-b2c msal.js