Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Last active April 22, 2020 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manoj-choudhari-git/c9ef2d2fba1eb134f810e397ca714b2f to your computer and use it in GitHub Desktop.
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
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