角度11:Msal Angular V2包出现问题
我已经将我的angular项目从v8升级到v11。 我已经将@azure/msal angular软件包从V1升级到V2(2.0.0-beta.3)。 我已跟踪上所给的样品 在Azure portal上完成的配置与早期版本配合良好。这是一个SSO应用程序,没有登录按钮角度11:Msal Angular V2包出现问题,angular,azure,msal-angular,Angular,Azure,Msal Angular,我已经将我的angular项目从v8升级到v11。 我已经将@azure/msal angular软件包从V1升级到V2(2.0.0-beta.3)。 我已跟踪上所给的样品 在Azure portal上完成的配置与早期版本配合良好。这是一个SSO应用程序,没有登录按钮 应用程序模块 const isIE = window.navigator.userAgent.indexOf("MSIE ") > -1 || window.navigator.userAgent.i
const isIE = window.navigator.userAgent.indexOf("MSIE ") > -1 ||
window.navigator.userAgent.indexOf("Trident/") > -1;
export function loggerCallback(logLevel: LogLevel, message: string) {
console.log(message);
}
export function MSALInstanceFactory(): IPublicClientApplication {
return new PublicClientApplication({
auth: {
clientId: environment.clientId,
authority:
`https://login.microsoftonline.com/${environment.tenantName}`,
redirectUri: environment.redirectUrl
},
cache: {
cacheLocation: BrowserCacheLocation.LocalStorage,
storeAuthStateInCookie: isIE,
},
system: {
loggerOptions: {
loggerCallback,
logLevel: LogLevel.Info,
piiLoggingEnabled: false
}
}
});
}
export function MSALInterceptorConfigFactory():
MsalInterceptorConfiguration {
const protectedResourceMap = new Map<string, Array<string>>();
protectedResourceMap.set(`${environment.clientId}`,
[`${environment.scopeUrl}`]);
return {
interactionType: InteractionType.Redirect,
protectedResourceMap
};
}
export function MSALGuardConfigFactory(): MsalGuardConfiguration {
return {
interactionType: InteractionType.Redirect,
authRequest: {
scopes: [`${environment.scopeUrl}`]
},
};
}
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: MsalInterceptor,
multi: true
},
{
provide: MSAL_INSTANCE,
useFactory: MSALInstanceFactory
},
{
provide: MSAL_GUARD_CONFIG,
useFactory: MSALGuardConfigFactory
},
{
provide: MSAL_INTERCEPTOR_CONFIG,
useFactory: MSALInterceptorConfigFactory
},
环境
scopeUrl: "api://xxxxxxx-xxxx-xxxx-a247-6023a95xxxxx/api",
clientId: "b4f868f3-xxxx-xxxx-xxxx-4d44f053ff29",
tenantName: "83993965-xxxx-xxxx-xxxx-d8259608fd30",
scope: "user.read",
appUrl: "http://localhost:4300/",
location: "localStorage",
graphUrl: "https://graph.microsoft.com/v1.0/me"
但现在,升级的msal包无法使用相同的配置。
我正在犯错误
http Post调用:
错误响应:
error_codes: [7000218]
error_description: "AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
↵Trace ID: f0843107-bd57-4d08-b92e-15a873724e00
↵Correlation ID: 1764d345-xxxx-xxx-xxxx-20a9fda5bcb6
↵Timestamp: 2021-04-14 12:58:22Z"
error_uri: "https://login.microsoftonline.com/error?code=7000218"
如果您在Angular Project中从msal V1升级到V2,我们将不胜感激。你必须在Azure AD中执行同样的操作。我在Azure目录中删除了当前的Azure应用程序Id,并按照下面MS文档中提到的过程为MSAL 2.0创建了一个新的应用程序Id 注册Azure AD并设置allowPublicClient=true 注意:使用模板“单页应用程序”创建新的应用程序ID。检查清单中重定向URI的类型是否为“Spa”,而不是“Web”。如果存在“Web”,则将其删除
error_codes: [7000218]
error_description: "AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
↵Trace ID: f0843107-bd57-4d08-b92e-15a873724e00
↵Correlation ID: 1764d345-xxxx-xxx-xxxx-20a9fda5bcb6
↵Timestamp: 2021-04-14 12:58:22Z"
error_uri: "https://login.microsoftonline.com/error?code=7000218"