2017-08-16 34 views
2

我使用的示例来自:https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp作为实现B2C注册的基础。使用msal连接到Azure B2C - 状态参数

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

+0

你能提供一个'我看到有关国家的问题'的链接吗? – spottedmahn

回答

2

在审阅source code for MSAL.js时,我看不到您如何控制state的值。 AuthenticationRequestParameters没有公开,并且当AuthenticationRequestParametersconstructedstate的值被设置为新的guid。


在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); 
     ... 
    }); 
    ... 
} 
+0

我很好奇。如果库正在创建状态参数,那么将它暴露给用户有什么好处? – user911

+1

查看[this SO Post](https://stackoverflow.com/a/47546311/1851230)关于使用状态参数来控制重定向。 @ user911 – spottedmahn