【发布时间】:2018-02-08 23:34:39
【问题描述】:
您好,我正在使用下面的代码使用 AAD b2C 登录,它正在重定向到登录页面,并且如果用户 ID 和 apsswords 正确,它将重定向回 localhost:4200 而不获取登录详细信息,当我在检查控制台的日志,它显示错误拒绝显示在 iframe 中,因为它将“X-Frame-Options”设置为“拒绝”,这是由于 iframe 选项。但是如何解决这个问题,请帮忙。
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);
});
});
}
}
【问题讨论】:
标签: angular azure typescript adal msal