我使用Azure AD B2C门户生成令牌。当我使用loginPopup方法时,我可以成功生成Token,但在使用loginRedirect时获得undefined
。在Azure AD中使用loginRedirect生成访问令牌B2C门户
下面的代码:
clientApplication = new Msal.UserAgentApplication(
this.tenantConfig.clientID, this.authority,
function (errorDesc: any, token: any, error: any, tokenType: any) {
// Called after loginRedirect or acquireTokenPopup
}
);
public login(): void {
var _this = this;
// loginRedirect loginPopup
this.clientApplication.loginPopup(this.tenantConfig.b2cScopes).then(function (idToken: any) {
_this.clientApplication.acquireTokenSilent(_this.tenantConfig.b2cScopes).then(
function (accessToken: any) {
_this.access_token = accessToken;
}, function (error: any) {
_this.clientApplication.acquireTokenPopup(_this.tenantConfig.b2cScopes).then(
function (accessToken: any) {
_this.access_token = accessToken;
}, function (error: any) {
bootbox.alert("Error acquiring the popup:\n" + error);
});
})
}, function (error: any) {
bootbox.alert("Error during login:\n" + error);
});
console.log(`access token service file ${_this.access_token}`);
}
请让我知道我在做什么错误?是范围问题还是回调方法问题?
我在msal.nonce.idtoken中找到了此内容 –