[英]Generating access Token with loginRedirect in Azure AD B2C portal
I am generating token using Azure AD B2C Portal. 我正在使用Azure AD B2C Portal生成令牌。 When I am using loginPopup method then I can generate Token successfully but got
undefined
while using loginRedirect. 当我使用loginPopup方法时,我可以成功生成令牌,但在使用loginRedirect时
undefined
。
here's the code: 这是代码:
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}`);
}
Please let me know what mistake I am doing? 请让我知道我在做什么错? is it Scope issue OR callback method issue?
是范围问题还是回调方法问题?
For loginRedirect
you add your handler code of the response in // Called after loginRedirect or acquireTokenPopup
block. 对于
loginRedirect
您将响应的处理程序代码添加在// Called after loginRedirect or acquireTokenPopup
块// Called after loginRedirect or acquireTokenPopup
。
clientApplication = new Msal.UserAgentApplication(
this.tenantConfig.clientID, this.authority,
function (errorDesc: any, token: any, error: any, tokenType: any) {
// Called after loginRedirect or acquireTokenPopup
// perform your logic HERE! :)
}
);
public login(){
this.clientApplication.loginRedirect(this.tenantConfig.b2cScopes);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.