我使用的样本来自:https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp作为实现 B2C 注册的基础。
如何在示例中传递 state 参数?我看到有一个关于状态的问题,所以我想可以在示例中使用状态。但是,我无法弄清楚如何使用它以及在返回 token 后如何检索它。
最佳答案
在审查 source code for MSAL.js ,我不明白你如何控制state
的值. AuthenticationRequestParameters
未暴露且值state
当 AuthenticationRequestParameters
时设置为新的 guid是 constructed .
示例 :
在以下 MSAL.js 代码中,我们无法控制 authenticationRequest
多变的。
loginRedirect(scopes? : Array<string> , extraQueryParameters? : string): void {
...
this.authorityInstance.ResolveEndpointsAsync()
.then(() => {
const authenticationRequest = new AuthenticationRequestParameters(this.authorityInstance, this.clientId, scopes, ResponseTypes.id_token, this._redirectUri);
...
});
...
}
关于azure-ad-b2c - 使用 msal 连接到 Azure B2C - 状态参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45705403/