0

SSO 失败“ServerError:AADSTS50058:已发送静默登录请求,但当前登录的用户均未与请求的登录提示匹配”,当我为工作帐户和个人 Azure 帐户使用相同帐户时。

我有 2 个 AAD 帐户(一个是我的工作帐户,另一个是个人帐户,但都附有相同的电子邮件,并且都使用相同的凭据)。当我使用 msal.js 库进行单点登录应用程序时。它会将我带到我的工作帐户,它要求我通过提供完整的电子邮件地址来验证凭据(使用标准弹出对话框),并且即使提供正确的凭据也无法正确验证。由于我需要使用我的个人帐户登录,我希望这应该使用我的广告 alias@company.com 凭据进行验证。我尝试在对话框中使用不同的帐户选项,但它失败并显示相同的完整电子邮件帐户。如何使用我的 adalias@company.com 作为默认用户 ID?

这是我尝试使用的一段代码。

var msalConfig = {
     auth: {
       clientId: 'xxxxxxxxxx', // This is your client ID
       authority: "https://login.microsoftonline.com/{tenantid}"  // This is tenant info
     },
     cache: {
       cacheLocation: "localStorage",
       storeAuthStateInCookie: true
     }
};

var graphConfig = {
  graphMeEndpoint: "https://graph.microsoft.com/v1.0/me"
};

var requestObj = {scopes: ["user.read", "email"]};  
// Is there a way to change here to get the required user id?

var myMSALObj = new Msal.UserAgentApplication(msalConfig);
// Register Callbacks for redirect flow     
myMSALObj.handleRedirectCallbacks(acquireTokenRedirectCallBack, 
acquireTokenErrorRedirectCallBack);
myMSALObj.handleRedirectCallback(authRedirectCallBack);

function signIn() {
  myMSALObj.loginRedirect(requestObj).then(function (loginResponse) {
    // Successful login        
    acquireTokenPopupAndCallMSGraph();
  }).catch(function (error) {
    // Please check the console for errors
    console.log(error);
  });
}

这是我收到的错误消息:

ServerError:AADSTS50058:已发送静默登录请求,但当前登录的用户均不匹配请求的登录提示

预期结果是无缝登录到其他应用程序。

4

1 回答 1

0

如果您想提供 login_hint 来指示您尝试验证的用户,请尝试:

var requestObj = {scopes: ["user.read", "email"], loginHint: "adalias@company.com"};

参考https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/FAQs#q10-how-to-pass-custom-state-parameter-value-in-msaljs-authentication-request-for -example-when-you-want-to-pass-the-page-the-user-is-on-or-custom-info-to-your-redirect-uri

于 2020-02-19T22:35:46.697 回答