Angular MSAL
About this package
This package is created when @azure/msal wasn't ready to use. Because there are so many configuration options, this packages tries to make things easier. See the demo project for a working example using login-redirect and login-popup.
Installation
npm install angular-msal --save
Usage
This is how I use the package: I have a userService that has a function: TryToGetUser, which tries to get the current user from my backend (using the tokens ObjectId which I make sure is equal to my User.Id)
Add the MsalModule and HttpIntercepter in app.module.ts
@
providers: UserService provide: HTTP_INTERCEPTORS useClass: MsalInterceptor multi: true
@ cachedUser: User; { } public { if thisauthService return this; return ofnull; } public { return thishttpget<User>`User/loggedinuser`; }
login.component.ts
{ thisauthService; { const response = await thismsalService; if responseidToken thisrouter; }
To logout use
thismsalService;