Azure msal.js loginRedirect()重复重定向到登录窗口react.js
我们正在使用Active Directory(Azure AD)v2.0端点,并使用msal.js进行登录,其反复要求登录Azure msal.js loginRedirect()重复重定向到登录窗口react.js,azure,azure-active-directory,msal.js,Azure,Azure Active Directory,Msal.js,我们正在使用Active Directory(Azure AD)v2.0端点,并使用msal.js进行登录,其反复要求登录 let app = new Msal.UserAgentApplication( applicationConfig.clientID, 'https://login.microsoftonline.com/common', (errorDesc,token,error,tokenType)=>{ if(token){
let app = new Msal.UserAgentApplication(
applicationConfig.clientID,
'https://login.microsoftonline.com/common',
(errorDesc,token,error,tokenType)=>{
if(token){
localStorage.setItem(userAdTokenName,token);
window.location.href='/';
}
},
{
redirectUri:redirectUri,
cacheLocation:'localStorage'
}
);
export function login(){
app.loginRedirect(applicationConfig.scopes);
}
提前谢谢 您还可以在每个页面上使用SPFx扩展,以便登录弹出窗口现在能够关闭。重定向URL(SPFx/AAD)必须指定根网站集 另外,我听说这是msal某些版本的问题。您可以尝试降级到msal 0.1.3以解决此问题 根据这一点,在应用程序重定向到的页面上包括MSAL
UserAgentApplication
对象
// This is weird but Microsoft login redirects back to the site and expects it to create the object before it closes the popup.
// See https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/174
if (location.hash.includes("id_token")) {
new UserAgentApplication("4ecf3d26-e844-4855-9158-b8f6c0121b50", null, null);
}
一位评论员表示,他将此代码放在他的组件willmount
方法中。上面的代码片段是从github一字不差地发布的,但是我相信对includes
方法的正确调用应该在window.location.hash
上。我试过了,但没能成功,但其他人说这对他们有效
请更新您的文章,如果你得到它的工作。我几乎一整天都在做这件事,还不明白为什么窗户不会消失。我正在构建SPA,因此理论上,UserAgentApplication
对象位于每个“页面”上