2

我收到此错误:

Access to XMLHttpRequest at 'https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize/.well-known/openid-configuration' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

尝试重定向到 azure 进行登录时。

这是服务:

export class AuthService {
private _userManager: UserManager;

constructor(private http: HttpClient) {
    const config = {
        authority: Constants.stsAuthority,
        client_id: Constants.clientId,
        redirect_uri: `${Constants.clientRoot}assets/oidc-login-redirect.html`,
        scope: 'openid profile',
        response_type: 'id_token token',
        post_logout_redirect_uri: `${Constants.clientRoot}?postLogout=true`,
        userStore: new WebStorageStateStore({ store: window.localStorage })
      };
    this._userManager = new UserManager(config)
 }

 login(): Promise<any>{
     return this._userManager.signinRedirect();
 }

}

我确定我正确注册了我的localhost网址。然而,我得到了那个错误。到目前为止,我没有看到任何处理该问题的文档。

感谢您的帮助

在此处输入图像描述

4

1 回答 1

3

https://login.microsoftonline.com/ {tenantId}/oauth2/v2.0/authorize/.well-known/openid-configuration 不是有效的 URL。

可能您的权限配置错误。应该只是https://login.microsoftonline.com/tenant-id

于 2019-09-07T13:41:09.877 回答