skip to Main Content

I am getting this error when running my angular code on local the

enter image description here

enter image description here

I have checked my logout url is https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession/ and my redirect url is "redirectUri": "https://127.0.0.1:8007"

2

Answers


  1. Chosen as BEST ANSWER

    There are several steps are involved

    1. I have added my self on AAD group.
    2. Changed Logout URL on azure.
    3. changed 127.0.0.1 to localhost.

  2. As I mentioned in the comments, I used the redirect URI "http://localhost:4200" in my code and was able to successfully log in and log out with Azure AD without any issues.

    Below is my Code.

    src/app/module.ts_ :

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { MsalModule, MsalService, MSAL_INSTANCE } from '@azure/msal-angular';
    import { IPublicClientApplication, PublicClientApplication } from '@azure/msal-browser';
    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    
    export function MSALInstanceFactory(): IPublicClientApplication {
      return new PublicClientApplication({
        auth: {
          clientId: '<client_ID>', 
          authority: 'https://login.microsoftonline.com/<Tenant_ID>', 
          redirectUri: 'http://localhost:4200' 
        },
        cache: {
          cacheLocation: 'localStorage',
          storeAuthStateInCookie: true
        }
      });
    }
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        AppRoutingModule,
        MsalModule
      ],
      providers: [
        {
          provide: MSAL_INSTANCE,
          useFactory: MSALInstanceFactory
        },
        MsalService
      ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    
    

    Output :

    It runs successfully as below:

    enter image description here

    enter image description here

    enter image description here

    Next, I click on the Logout button, and it shows my account to logout as below:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search