This is a wrapper module to authenticate Angular applications to the Azure v2 endpoint. A working example can be found at: https://github.com/benbaran/msal-angular-example .
- Added an option to redirect instead of the popup login
- Added configuration options navigateToLoginRequestUrl, redirectUrl and callback.
- Fixed authenticated() returning true when token is expired.
- Updated msal from 0.14 to 0.15.
- authenticated() and getUser() return a Promise.
- Updated for Angular 5
- Several improvements contributed by Marcelh1983
- Updated build system
- Initial version for Angular 4.
- Create a new app at apps.dev.microsoft.com
- Add the Web platform for your app
- Set the Redirect URI - for Angular CLI development this will be https://localhost:4200/
- Enable Allow Implicit Flow
- Copy the Application Id for use in the configuration
npm install msal-angular --save
@NgModule({
imports: [MsalModule.forRoot({
clientID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
graphScopes: ["openid"],
authority: 'https://login.microsoftonline.com/<tenant>.onmicrosoft.com'
})]
})
export class AppModule { }
constructor(private msalService: MsalService) { }
login() {
this.msalService.login();
}
logout() {
this.msalService.logout();
}
get authenticated(): Promise<boolean> {
return this.msalService.authenticated;
}
- clientID: Specifies the Azure AD client id/application Id of the calling web service;
- graphScopes: Allows the client to express the desired scope of the access request;
- signUpSignInPolicy: Name of the Sign-up or sign-in policy (optional*);
- tenant: Url of the tenant xxx.onmicrosoft.com (optional*)
- popup: show login popup or redirect (optional, default: true);
- navigateToLoginRequestUrl: Ability to turn off default navigation to start page after login. (optional, default: false);
- redirectUrl: Location to redirect, can be a relative of absolute url. (optional, default: window.location.href);
- callback: Callback function after login;
* signUpSignInPolicy and tenant will only be applied when both values are filled.