1
嗨我正在使用下面的代码登录使用AAD b2C,它重定向到登录页面,如果用户ID和密码正确,它会重定向回localhost:4200而不会获取登录详细信息,当我检查控制台的日志时,它显示拒绝显示在iframe中的错误,因为它设置了'X-Frame-Options '去'否认是由于iframe选项。但如何解决这个问题,请帮忙。MSAL与Angular2:拒绝在框架中显示,因为它将'X-Frame-Options'设置为'拒绝'
import { Injectable } from '@angular/core';
import '../../../node_modules/msal/out/msal';
/// <reference path="../../../node_modules/msal/out/msal.d.ts"
@Injectable()
export class AuthService {
private applicationConfig: any = {
clientID: 'df7cc9df-8073-4017-a108-85869852',
authority: "https://login.microsoftonline.com/tfp/mylogintest.onmicrosoft.com//B2C_1_SiUpIn",
b2cScopes: ["https://mylogintest.onmicrosoft.com/user.read"],
webApi: 'http://localhost:4200',
};
private app: any;
constructor() {
this.app = new Msal.UserAgentApplication(this.applicationConfig.clientID, this.applicationConfig.authority, (errorDesc, token, error, tokenType) => {
// callback for login redirect
});
}
public login() {
return this.app.loginPopup(this.applicationConfig.b2cScopes).then(idToken => {
this.app.acquireTokenSilent(this.applicationConfig.b2cScopes).then(accessToken => {
// updateUI();
console.log(this.app.getUser());
}, error => {
this.app.acquireTokenPopup(this.applicationConfig.b2cScopes).then(accessToken => {
console.log(this.app.getUser());
// updateUI();
}, error => {
console.log("Error acquiring the popup:\n" + error);
});
})
}, error => {
console.log("Error during login:\n" + error);
});
}
public logout() {
this.app.logout();
}
public getToken() {
return this.app.acquireTokenSilent(this.applicationConfig.graphScopes)
.then(accessToken => {
return accessToken;
}, error => {
return this.app.acquireTokenPopup(this.applicationConfig.graphScopes)
.then(accessToken => {
return accessToken;
}, err => {
console.error(err);
});
});
}
}