首页 文章

使用msal连接到Azure B2C - 状态参数

提问于
浏览
2

我使用的样本:https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp作为实施B2C注册的基础 .

如何在示例中传递state参数?我看到有一个关于状态的问题,所以我想在示例中可以使用state . 但是,我无法弄清楚如何使用它以及如何在返回令牌后检索它 .

1 回答

  • 2

    在审查source code for MSAL.js时,我看不出如何控制 state 的值 . 当 AuthenticationRequestParametersconstructed时, AuthenticationRequestParameters 未暴露, state 的值设置为新的guid .


    Example

    在以下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);
            ...
        });
        ...
    }
    

相关问题