【发布时间】: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