2017-08-16 33 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