Last active
April 22, 2020 20:28
-
-
Save manoj-choudhari-git/c9ef2d2fba1eb134f810e397ca714b2f to your computer and use it in GitHub Desktop.
This is demonstration of how Azure AD authentication can be configured for Angular application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'; | |
import { MsalModule, MsalInterceptor } from '@azure/msal-angular'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
export const protectedResourceMap: [string, string[]][] = [ | |
['https://graph.microsoft.com/v1.0/me', ['user.read']] | |
]; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
MsalModule.forRoot( | |
{ | |
auth: { | |
// This is your client ID | |
clientId: 'd471db94-db21-4103-aefa-679cd7435745', | |
// The GUID is your Directory (or tenant) ID | |
authority: 'https://login.microsoftonline.com/d26c9159-7165-4322-bf28-6c98626e9619', | |
// This is your redirect URI | |
redirectUri: 'http://localhost:4200', | |
postLogoutRedirectUri: "http://localhost:4200", | |
navigateToLoginRequestUrl: true, | |
}, | |
cache: { | |
cacheLocation: 'localStorage', | |
storeAuthStateInCookie: false, // Set to true for Internet Explorer 11 | |
}, | |
}, | |
{ | |
popUp: false, | |
consentScopes: [ | |
"user.read", | |
"openid", | |
"profile", | |
], | |
unprotectedResources: ["https://www.microsoft.com/en-us/"], | |
protectedResourceMap, | |
extraQueryParameters: {} | |
} | |
), | |
BrowserModule, | |
AppRoutingModule | |
], | |
providers: [], | |
bootstrap: [AppComponent] | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment