- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 Azure AD B2C 为 Angular 2+ 应用程序实现身份验证。发现这个很棒 example .但是,该示例在弹出窗口中进行身份验证。我宁愿使用重定向而不是弹出窗口。 MSAL Service 的代码弹出验证如下:
import { Injectable } from '@angular/core';
declare var bootbox: any;
declare var Msal:any;
@Injectable()
export class MsalService {
access_token: string;
tenantConfig = {
tenant: "fabrikamb2c.onmicrosoft.com",
clientID: '90c0fe63-bcf2-44d5-8fb7-b8bbc0b29dc6',
signUpSignInPolicy: "b2c_1_susi",
b2cScopes: ["https://fabrikamb2c.onmicrosoft.com/demoapi/demo.read"]
};
// Configure the authority for Azure AD B2C
authority = "https://login.microsoftonline.com/tfp/" + this.tenantConfig.tenant + "/" + this.tenantConfig.signUpSignInPolicy;
/*
* B2C SignIn SignUp Policy Configuration
*/
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;
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);
});
}
logout(): void {
this.clientApplication.logout();
};
isOnline(): boolean {
return this.clientApplication.getUser() != null;
};
}
如何使用 loginRedirect
而不是 loginPopup
更改此代码以执行相同的操作?
最佳答案
从 .loginPopup(blah).then()...
中获取您在 then
中的代码,并将其放入 //调用的 block 中在 loginRedirect 或 acquireTokenPopup
之后。
关于angular - 如何使用 loginRedirect 而不是 loginPopup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46417709/
我正在尝试使用 Azure AD B2C 为 Angular 2+ 应用程序实现身份验证。发现这个很棒 example .但是,该示例在弹出窗口中进行身份验证。我宁愿使用重定向而不是弹出窗口。 MSA
我没有从使用 MSAL 库的 UserAgentApplication 实例的 loginPopup(requestObj) 获得 loginResponse。 Azure 示例用作 https://
(继续问题:Why is my SPA, which is calling my WebAPI, using Azure Active Directory, receiving "Authorizat
(继续问题:Why is my SPA, which is calling my WebAPI, using Azure Active Directory, receiving "Authorizat
当我调用“msal-Angular”的MsalService.loginPopup时,它自己的页面会像这样弹出。 当我从自定义登录并尝试从默认域(从 Azure 静态 Web 应用程序发布)登录时,会
当我调用“msal-Angular”的MsalService.loginPopup时,它自己的页面会像这样弹出。 当我从自定义登录并尝试从默认域(从 Azure 静态 Web 应用程序发布)登录时,会
我是一名优秀的程序员,十分优秀!