除装饰器以外的MSAL的外部配置

问题描述

我是Angular的新手,最近被要求从事MSAL工作。这就是我配置MSAL的方式。

在应用模块下导入

MsalModule.forRoot({
  auth: {
    clientId: 'myclientid',// This is your client ID
    authority: 'https://login.microsoftonline.com/tenantid',// This is your tenant ID
    redirectUri: 'http://localhost:4200'// This is your redirect URI
    //redirectUri: 'https://myapiurl.com'// This is your redirect URI
  },cache: {
    cacheLocation: 'localStorage',storeAuthStateInCookie: isIE,// Set to true for Internet Explorer 11
  },},{
  popUp: !isIE,consentScopes: [
              'user.read',          'openid',          'apiguid/user_impersonation',        ],unprotectedResources: [],protectedResourceMap: [
              [
                'https://localhost:44331/',            ['apiguid/user_impersonation'],          ],          [
                'https://myapiurl.com/userimpersonation/',extraQueryParameters: {}
})

但是我的问题是,因为配置位于装饰器中,所以我发现很难为诸如ClientID之类的每个属性使用动态值。

因此,MSAL中可以通过任何方式将配置作为JSON文件或其他功能加载

解决方法

我有一个解决方案,我认为这是一个非常好的解决方案,并且可以使它起作用。

分享给遇到相同问题的人

How to initialize msal configurations using APP_INITIALIZER

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...