Microsoft-authentication-library-for-js: MsalModule.forRoot throws AoT error

Created on 9 Aug 2018  路  8Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Current behavior


The MsalModule.forRoot function throws an AoT error when compiling with v6.1.
It may have to do with the use of the window object. The compiler throws error: Error: Internal error: unknown identifier undefined

Expected behavior


I expect AoT compilation to work, regardless of version. If it is because of the Window interface being used as an injection token, a fix is described here: https://github.com/angular/angular/issues/12631#issuecomment-274260009

Minimal reproduction of the problem with instructions


Import MsalModule with any forRoot configuration and compile with Angular compiler > v6 and use --aot flag.

bug

All 8 comments

@sharppc Thanks for reporting this. I will be doing another release in this week.

Having the same issue. If I remove the MsalModule from my app, the AOT compilation error goes away.

@RobARichardson @sharppc This is fixed and released in @azure/msal-angular 0.1.1 . Please check.

Thanks, @nehaagrawal. Compilation error is gone, but I'm now seeing this warning in its place

WARNING in ./src/app/app.module.ngfactory.js
85:19195-19212 "export 'WindowWrapper' (imported as 'i52') was not found in '@azure/msal-angular/dist/msal.module'

Furthermore, while I'm not 100% certain this is related, when my app is compiled for production, Msal no longer appears to be adding the Authorization Token to the Http Request Headers therefore all XHR requests are getting a 401 Unauthorized.

@RobARichardson This is working fine. Can you please try our sample here and run "ng build --prod --aot". I was able to the token and it was added in the header.

@nehaagrawal I pulled down the sample and tried it. When I run the app using "ng serve", everything works normally. However, when I run the app using "ng serve --prod --aot", I'm seeing the same behavior as my own app: the requests to graph.microsoft.com/v1.0/me are missing the Authorization header and fail due to a 401 Unauthorized.

@RobARichardson Sorry I didn't get earlier that you were running "ng serve --prod --aot" instead of "ng serve". I was trying to build it using aot using "ng build --prod --aot" and then run it using "ng serve" and hence I couldn't reproduce it. I can reproduce it now. I will fix it and release it soon. Thanks for reporting this.

@RobARichardson This is fixed and released in msal-angular 0.1.2. You will need to change the way you pass the protectedResourceMap. Please check readme for more details.

Was this page helpful?
0 / 5 - 0 ratings