小编0xd*_*eef的帖子

使用 loginPopup 时 Microsoft 身份验证反应“hash_empty_error”

我无法理解在尝试使用 Micrsoft Authentication 库 for React (PWA) 对用户进行身份验证时遇到的错误。我需要帮助理解为什么尝试使用 loginPopup 方法登录用户时失败。

在某些情况下,身份验证按预期工作,但在某些情况下却不起作用。任何形式的建议和/或帮助将不胜感激。

以下是我配置 microsoft 身份验证库的方式:

// create the microsoft signin configuration object
const msalConfig = {
  auth: {
    clientId   : process.env.REACT_APP_APP_CLIENT_ID,
    authority  : "https://login.microsoftonline.com/common/",
    redirectUri: window.location.origin,
  },
  cache: {
    cacheLocation: "sessionStorage",
  }
};

// initialize the user egent of the application 
const msalInstance = new msal.PublicClientApplication(msalConfig);
Run Code Online (Sandbox Code Playgroud)

这是我调用 loginPopup 方法的块,该方法应该返回一个承诺,该承诺在该函数完成时得到满足,或者在出现错误时被拒绝。

const handleMicrosoftSignin = async () => {
  try {
    // this function does not get fulfilled, hence a 'hash_empty-err' 
    let msalResponse = …
Run Code Online (Sandbox Code Playgroud)

single-page-application reactjs msal.js msal-react

7
推荐指数
1
解决办法
3320
查看次数