【问题标题】:error AADSTS7000218 (@azure/msal-react, @azure/msal-browser) SPA whit React Js y Azure ad错误 AADSTS7000218 (@azure/msal-react, @azure/msal-browser) SPA whit React Js y Azure 广告
【发布时间】:2021-09-24 11:31:50
【问题描述】:

早上好,您是否曾经将 Azure AD 与使用 REACT 制作的应用程序集成??我按照 Microsoft 文档(@azure / msal-react 和 @azure / msal-browser)的步骤进行操作 似乎执行了使用电子邮件和密码的身份验证,但是在重定向到页面时,我收到带有图例的错误 AADSTS7000218:“请求正文必须包含以下参数:'client_assertion' 或 'client_secret'”。 问题是我不是 Azure 管理员,并且我已经要求将某些特定设置(例如 AllowPublicClients 设置为 true),但没有其他任何设置。

这是我的配置文件:

import { LogLevel } from "@azure/msal-browser";
// Browser check variables
// If you support IE, our recommendation is that you sign-in using Redirect APIs
// If you as a developer are testing using Edge InPrivate mode, please add "isEdge" to the if check
const ua = window.navigator.userAgent;
const msie = ua.indexOf("MSIE ");
const msie11 = ua.indexOf("Trident/");
const msedge = ua.indexOf("Edge/");
const firefox = ua.indexOf("Firefox");
const isIE = msie > 0 || msie11 > 0;
const isEdge = msedge > 0;
const isFirefox = firefox > 0; // Only needed if you need to support the redirect flow in Firefox incognito

// Config object to be passed to Msal on creation
export const msalConfig = {
  auth: {
    clientId: process.env.REACT_APP_CLIENT_ID ,
    authority:
      `https://login.microsoftonline.com/${process.env.REACT_APP_TENANT_ID}`,
    redirectUri: process.env.REACT_APP_HOST,
    clientSecret: process.env.REACT_APP_CLIENT_SECRET,
  },
  cache: {
    storeAuthStateInCookie: isIE || isEdge || isFirefox,
  },
  system: {
    loggerOptions: {
      loggerCallback: (level, message, containsPii) => {
        if (containsPii) {
          return;
        }
        switch (level) {
          case LogLevel.Error:
            console.error(message);
            return;
          case LogLevel.Info:
            console.info(message);
            return;
          case LogLevel.Verbose:
            console.debug(message);
            return;
          case LogLevel.Warning:
            console.warn(message);
            return;
          default:
            return;
        }
      },
    },
  },
};

// Add here scopes for id token to be used at MS Identity Platform endpoints.
export const loginRequest = {
  scopes: ["profile"],
};

// Add here the endpoints for MS Graph API services you would like to use.
export const graphConfig = {
  graphMeEndpoint: "https://graph.microsoft.com/v1.0/me",
};

【问题讨论】:

    标签: reactjs azure-active-directory single-sign-on


    【解决方案1】:

    我建议您获得管理权限以启用已为在 Azure AD 中注册的应用程序禁用的允许公共客户端流或尝试免费订阅(您作为所有者)

    启用它可以解决问题。

    如果应用程序预计是机密客户端,则提供客户端机密或断言。在您不希望客户端应用程序保密的某些身份验证流程场景(例如 ROPC 或设备代码流程)中,请按照以下步骤将默认类型更改为公共客户端。

    第 1 步:转到此应用的应用注册

    第 2 步:选择“身份验证”-> 在默认客户端类型处勾选“是”-> 保存更改

    参考:https://nishantrana.me/2020/12/01/fixed-aadsts7000218-the-request-body-must-contain-the-following-parameter-client_assertion-or-client_secret/

    https://blogs.aaddevsup.xyz/2019/08/receiving-error-aadsts7000218-the-request-body-must-contain-the-following-parameter-client_assertion-or-client_secret/

    【讨论】:

      猜你喜欢
      • 2022-11-07
      • 2023-02-16
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 2022-09-30
      • 1970-01-01
      • 2023-04-02
      • 2022-12-06
      相关资源
      最近更新 更多