在Angular 8应用中的AppComponent_Host ngfactory js中得到错误[object Object]。

问题描述 投票:-1回答:1

我试图运行这个官方样本 角度应用 从Microsoft Identity平台(使用MSAL库来验证Azure AD用户),并得到以下错误。我无法弄清楚到底是哪个软件包或版本导致了这个错误,以及如何去修复它。有什么想法吗?

VM61 AppComponent_Host.ngfactory.js:6 ERROR Error: [object对象]在viewWrappedDebugError(VM21厂商.js:84484)在callWithDebugContext(VM21厂商.js:95180)在Object.debugCreateRootView[作为createRootView](VM21厂商.js:94680)在ComponentFactory_.push..node_modules@angularcorefesm5core.js.ComponentFactory_.create(VM21厂商.js:85367)在ComponentFactoryBoundToModule.push.node_modules@angularcorefesm5core. js.ComponentFactoryBoundToModule.create (VM21 vendor.js:83089) at ApplicationRef.push..node_modules@angularcorefesm5core.js.ApplicationRef.bootstrap (VM21 vendor.js:91935) at VM21 vendor.js:91657 at Array.forEach () at PlatformRef.push..node_modules@angularcorefesm5core.js.PlatformRef._moduleDoBootstrap (VM21 vendor.js:91657) at VM21 vendor.js:91625。

enter image description here

enter image description here

enter image description here

angular msal
1个回答
0
投票

Msal配置有问题。我在设置权限值时,只是设置了Tenant Id。指南 如下

 MsalModule.forRoot({
  auth: {
    clientId: 'xxxxxxxxxx-bxxxxx-4xxxxxx-9xxxxx-xxxxcf',
    authority: 'xxxxxxxxxx-dddxxxxx-ffffxxxxx-8xxxxx-xxxxcs',
    redirectUri: 'http://localhost:4202/',
  },
  cache: {
    cacheLocation: 'localStorage',
    storeAuthStateInCookie: isIE, // set to true for IE 11
  },
},
{
  popUp: !isIE,
  consentScopes: [
    'user.read',
    'openid',
    'profile',
  ],
  unprotectedResources: [],
  protectedResourceMap: [
    ['https://graph.microsoft.com/v1.0/me', ['user.read']]
  ],
  extraQueryParameters: {}
})

权限值应是: authority(or Cloud_Instance_Id)/tenantId 例如

https:/login.microsoftonline.comxxxxxxxxxx-dddxxxxx-ffffxxxxx-8xxxxx-xxxxcs。

我希望Angular或Msal库能有一个更好的errorexception显示,给我们一个指针,说明是Msal配置的问题。

希望它能帮助一些面临同样问题的人

© www.soinside.com 2019 - 2024. All rights reserved.