AADSTS900561:端点仅接受 POST、OPTIONS 请求。在 Angular UI 上收到 GET 请求

问题描述 投票:0回答:1

在本地运行我的角度代码时遇到此错误

enter image description here

enter image description here

我已检查我的注销网址是

https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession/
,我的重定向网址是
"redirectUri": "https://127.0.0.1:8007"

angular azure
1个回答
0
投票

正如我在评论中提到的,我在代码中使用了重定向 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 { }

输出

运行成功如下:

enter image description here

enter image description here

enter image description here

接下来,我点击Logout按钮,它会显示我的帐户要注销,如下所示:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.