我正在尝试为将与 Azure 和 React 集成的 B2C 身份验证应用程序获得完美的配置结构和授权 URL。我确实为我的配置文件获得了这个结构,并且在评论中指定了身份验证链接。但我无法获得弹出屏幕,并且错误表明授权链接无效。
import { LogLevel } from "@azure/msal-browser";
/**
* To learn more about user flows, visit: https://docs.microsoft.com/en-us/azure/active-directory-b2c/user-flow-overview
* To learn more about custom policies, visit: https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-overview
*/
const tenantName = "TenantName";
const signInPolicy = "Plicy_For_SignIn";
const applicationID = "CliendId";
const reactRedirectUri = "http://localhost:3000"; //RedirectURL
// Formatted as https://{b2ctenantname}.b2clogin.com/tfp/{b2ctenantguid or full tenant name including onmicrosoft.com}/{signuporinpolicyname}
const AuthorityUrl = `https://${tenantName}/tfp/${tenantName}/${signInPolicy}`;
/**
* https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/configuration.md
*/
export const msalConfig = {
auth: {
clientId: applicationID,
authority: AuthorityUrl,
redirectUri: reactRedirectUri,
},
cache: {
cacheLocation: "sessionStorage",
storeAuthStateInCookie: false,
},
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;
}
},
},
},
};
/**
* https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-permissions-and-consent#openid-connect-scopes
*/
export const loginRequest = {
scopes: ["User.Read"],
};
在使用相同并将其传递到 Index.js 文件的根目录后,通过包装它MsalProvider
并调用实例以进行弹出登录是行不通的。
我正在使用官方文档中提到的包@azure/msal-react
和@azure/msal-browser
我收到的错误400
后面是一条消息,上面写着:
ClientAuthError: endpoints_resolution_error: Error: could not resolve endpoints. Please check network and try again. Detail: ClientConfigurationError: untrusted_authority: The provided authority is not a trusted authority. Please include this authority in the knownAuthorities config parameter.
我需要一些帮助!
谢谢你!!