Reactjs 将MSAL(Microsoft身份验证库)与REDUX一起使用

Reactjs 将MSAL(Microsoft身份验证库)与REDUX一起使用,reactjs,redux,msal,Reactjs,Redux,Msal,我正在尝试使用REDUX中的MSAL库进行身份验证,但遇到了一些问题。当我制作一个只响应的应用程序并执行相同的操作时,我成功地获取了访问令牌,但尝试在REDUX中使用它时,在尝试获取访问令牌时,我总是得到一个超时 function Auth() { var userAgentApplication = new Msal.UserAgentApplication(*my app id*, null, function (errorDes, token, error, tokenType)

我正在尝试使用REDUX中的MSAL库进行身份验证,但遇到了一些问题。当我制作一个只响应的应用程序并执行相同的操作时,我成功地获取了访问令牌,但尝试在REDUX中使用它时,在尝试获取访问令牌时,我总是得到一个超时

function Auth() {
    var userAgentApplication = new Msal.UserAgentApplication(*my app id*, null, function (errorDes, token, error, tokenType) {
    // this callback is called after loginRedirect OR acquireTokenRedirect (not used for loginPopup/aquireTokenPopup)
    });

    return new Promise((resolve, reject) => { 
        console.log('inside the promise');
        userAgentApplication.loginPopup(["user.read"]).then((token) => {
            console.log("Successfully got id token");
            console.log("first token: ", token);
            console.log(userAgentApplication.getUser().name);
          userAgentApplication.acquireTokenSilent(["user.read"]).then((token) => {
            resolve(token);
        }, function(error) {
            reject(error);
        });
    }, function (error) {
        reject(error);
    });
});
}
这是我的代码,但我总是得到以下错误令牌更新操作失败,由于超时:null
当我尝试在纯HTML或仅反应应用程序中执行此操作时,它工作得非常好。任何形式的帮助都将不胜感激

查看添加“捕获”是否有助于识别问题

function Auth() {
  return new Promise((resolve, reject) => { 
    const userAgentApplication = new Msal.UserAgentApplication(*my app id*, null, function (errorDes, token, error, tokenType) {
      // this callback is called after loginRedirect OR acquireTokenRedirect (not used for loginPopup/aquireTokenPopup)
    });

    console.log('inside the promise');
    userAgentApplication.loginPopup(["user.read"])
    .then((token) => {
      console.log("Successfully got id token");
      console.log("first token: ", token);
      console.log(userAgentApplication.getUser().name);

      if (userAgentApplication.getUser()) {
        userAgentApplication.acquireTokenSilent(["user.read"])
        .then((token) => {
          resolve(token);
        })
        .catch((error) => {
          reject(error);
        });
      } else {
        reject("User not logged in");
      }
    })
    .catch((error) => {
      reject(error);
    });
  });
}