在本地运行我的角度代码时遇到此错误
我已检查我的注销网址是
https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession/
,我的重定向网址是 "redirectUri": "https://127.0.0.1:8007"
正如我在评论中提到的,我在代码中使用了重定向 URI“http://localhost:4200”,并且能够使用 Azure AD 成功登录和注销,没有任何问题。
以下是我的代码。
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 { }
输出:
运行成功如下:
接下来,我点击Logout按钮,它会显示我的帐户要注销,如下所示: