gpt4 book ai didi

angular - 在 Azure AD B2C 门户中使用 loginRedirect 生成访问 token

转载 作者:行者123 更新时间:2023-12-02 07:28:16 25 4
gpt4 key购买 nike

我正在使用 Azure AD B2C 门户生成 token 。当我使用loginPopup方法时,我可以成功生成 token ,但在使用loginRedirect时得到未定义

这是代码:

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}`);
}

请告诉我我犯了什么错误?是范围问题还是回调方法问题?

最佳答案

我找到了reference 。通过这个我能够获得访问 token 。您将在 sessionStorage.getItem('msal.idtoken') 中获取它。

关于angular - 在 Azure AD B2C 门户中使用 loginRedirect 生成访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46241091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com