Calling Protected API in APP_INITIALIZER #7169
Unanswered
brandonsmith86
asked this question in
Help
Replies: 2 comments
-
@brandonsmith86 have you found any solution so far? |
Beta Was this translation helpful? Give feedback.
0 replies
-
My solution was to drop the idea of initializing flags on app initialization. I instead put that logic in a custom route guard. This allows the MSAL flow to complete unimpeded. It wasn't what I wanted initially, but it has been working in production for a few months. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on an Angular project that uses @azure/msal-angular package. We are dynamically loading MSAL configuration in APP_INITIALIZER provider. This works fine. However, I also need to load feature flags in the initializer, to take advantage of feature-flag based route guards.
Based on what I've read, I need to configure the initializer to wait for MSAL to finish the login process. I believe the only way to do this is to inject
MsalService
orMsalBroadcastService
, and subscribe to one of the observables giving visibility into this process. The problem with this approach is that injecting these services into anAPP_INITIALIZER
automatically calls theMSAL_INSTANCE
provider, which must come after the configuration initializer. It's a bit of a chicken and the egg scenario.Anyway, if you have any guidance on how to accomplish this, please do let me know.
Beta Was this translation helpful? Give feedback.
All reactions