没有为使用Azure AD的Angular SPA提供资源标识符

我正在使用https://github.com/damienbod/dotnet-template-angular中经过修改的Visual Studio模板,通过带有Azure AD登录的Asp.Net API来构建Angular SPA。这使用Angular上的https://github.com/damienbod/angular-auth-oidc-client与Azure进行通信。

我获得了预期的Micosoft登录,但输入用户登录详细信息后,它返回错误:

AADSTS500013-未提供资源标识符

我在这里的其他一些问题中看到了此错误,但是使用不同的应用程序设置却未使用相同的Angular OIDC cliet。我不确定这是否是问题所在,还是我在Azure应用程序注册中缺少某些内容?

更新 我的Azure应用是使用旧版应用注册的,因此看起来像这样:

"oidc": {
    "issuer": "https://login.microsoftonline.com/[....]/","client_id": "[...]","scope": "openid","resource": "https://graph.microsoft.com/"
}
abxtoo 回答:没有为使用Azure AD的Angular SPA提供资源标识符

您是否已在用于验证用户身份的Azure AD中注册了应用程序?在那里,您将在appsettings.json节点下的clientId文件中为ASP.NET应用程序提供一个应用程序ID:

  "oidc": {
    "issuer": "https://login.microsoftonline.com/common/v2.0/","client_id": "d4d8dc5a-3e3b-4cf8-9ba5-eee9e27764a1","scope": "openid profile email","resource": "https://graph.windows.net","prompt": "consent"
  }

还要确保如dotnet-angular-azure-ad-oidc库的loadConfig函数的注释app.module.ts中所述,在Angular应用程序中包括Azure AD租户的OIDC配置。

export function loadConfig(oidcConfigService: OidcConfigService) {
  console.log('APP_INITIALIZER STARTING');
  // https://login.microsoftonline.com/damienbod.onmicrosoft.com/.well-known/openid-configuration
  // jwt keys: https://login.microsoftonline.com/common/discovery/keys
  // Azure AD does not support CORS,so you need to download the OIDC configuration,and use these from the application.
  // The jwt keys needs to be configured in the well-known-openid-configuration.json
  return () => oidcConfigService.load(`${window.location.origin}/api/config/configuration`);
  //return () => oidcConfigService.load_using_custom_stsServer('https://localhost:44347/well-known-openid-configuration.json');
}

此配置可通过https://login.microsoftonline.com/{your-tenant-name}.onmicrosoft.com/.well-known/openid-configuration访问。

本文链接:https://www.f2er.com/3152382.html

大家都在问