首页 > 解决方案 > 当升级到 msal 版本 1.xx 时,Angular 应用程序在 msal 0.x 错误 AADSTS700016 中工作正常

问题描述

export const protectedResourceMap: [string, string[]][] = [
  [environment.api_url, []]
];

const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1;
// const protectedResourceMap: [string, string[]][] = [
//   [environment.api_url, []]
// ];

@NgModule({
  declarations: [
    AppComponent,
   ProfileComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    FormsModule,
    ReactiveFormsModule,
    NgbModule,
    NgxSpinnerModule,
    ModalModule.forRoot(),
    RatingModule,
    NgxDaterangepickerMd.forRoot(),
    BlockUIModule.forRoot(),
    BrowserAnimationsModule,
    ToastrModule.forRoot({
      timeOut: 10000,
      maxOpened: 1,
      positionClass: "toast-top-right",
      preventDuplicates: true,
      closeButton: true,
    }),
    MsalModule.forRoot({
      auth: {
        clientId: environment.ida_client_id,
        authority: 'https://login.microsoftonline.com/common/', //+ environment.ida_tenant_id,
        validateAuthority: true,
        redirectUri: 'http://localhost:4200/',
        postLogoutRedirectUri: 'http://localhost:4200/',
        navigateToLoginRequestUrl: false,
      },
      cache: {
        cacheLocation: 'localStorage',
        storeAuthStateInCookie: isIE
      }
    },
    {
      popUp: !isIE,
      consentScopes: [
         'user.read',
         'openid',
         'profile',
        //'api://51a7124f-bc62-436b-8b7e-4c6eeae46f4f/access_as_user'
      ],
      unprotectedResources: ['https://www.microsoft.com/en-us/'],
      protectedResourceMap,
      extraQueryParameters: {}
    })
  ],
  providers: [
    UserService,
    AuthGuard,
    TicketsService,
    NewsService,
    DatePipe,
    BsModalRef,
    EventEmitterService,
    ConfirmedKBArticleService,
    SelfHealingService,
    FeaturesService,
    {
      provide: HTTP_INTERCEPTORS,
      //useClass: CustomHttpInterceptor,
      useClass:MsalInterceptor,
      multi: true,

标签: msal-angular

解决方案


推荐阅读