问题描述
我是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文件或其他功能加载
解决方法
我有一个解决方案,我认为这是一个非常好的解决方案,并且可以使它起作用。
分享给遇到相同问题的人