Azure AD B2C错误:请求中指定的客户端ID未在租户中注册

8
我正在尝试登录Azure Active Directory B2C应用程序。
每当我访问URL https://login.microsoftonline.com/te///oauth2/v2.0/authorize?client_id=...,就会出现以下错误:
“请求中指定的客户端ID 未在租户 中注册。”
以下是我的配置信息:
  • 我在 https://portal.azure.com 中创建了 Azure Active Directory B2C 租户,其中包含用户 globaladmin@<my_domain>.onmicrosoft.com

    • 为了创建应用程序,我导航到 https://apps.dev.microsoft.com,以全局管理员身份登录,并按照 此处的说明 创建了“Web Portal v2”应用程序
  • 我授予 Web Portal v2 访问 Microsoft Graph 的权限,但没有授予访问 Azure AD Windows Graph API 的权限(我在任何地方都没有看到此选项) enter image description here

  • 我可以成功导航到 https://portal.azure.com -> 查找 Azure AD B2C 资源 -> 点击进入 -> 应用程序。然后就有新创建的“Web Portal v2”

enter image description here

我的应用程序已经更新为"Web Portal v2"的新ClientId和ClientSecret。但是,当我启动应用程序并单击“登录”时,出现错误。我缺少哪些其他配置?

另外,我应该补充说明上述所有配置的原因是为了将我的应用程序从使用Azure AD V1令牌迁移到使用Azure AD V2令牌,这些令牌中包含有关User.Identity.Name等信息,这是我用来在应用程序右上角显示当前登录用户名称的值。如果有不同/更好的方法实现此目的,请告诉我。

3个回答

7
我认为这是因为当你通过AD blade(或Graph API)创建一个应用程序时,API权限没有预配。解决方法是将API权限添加到应用程序中:

Api Permissions default B2C

我刚刚经历了自动化这个过程,我可以告诉你,为了使用Graph API(注意:使用beta端点),必须配置四个层次。

  1. 创建应用程序 https://learn.microsoft.com/en-us/graph/api/application-post-applications?view=graph-rest-beta&tabs=http

  2. 更新应用程序属性 https://learn.microsoft.com/en-us/graph/api/application-update?view=graph-rest-beta&tabs=http a. requiredResourceAccess https://learn.microsoft.com/en-us/graph/api/resources/requiredresourceaccess?view=graph-rest-beta b. 其他属性,例如implicitGrantSettings、logoutUrl等

  3. 为刚创建的应用程序创建服务主体:https://learn.microsoft.com/en-us/graph/api/serviceprincipal-post-serviceprincipals?view=graph-rest-beta&tabs=http

  4. 使用服务主体的对象 ID 创建 oauth2PermissionGrants:https://learn.microsoft.com/en-us/graph/api/oauth2permissiongrant-post?view=graph-rest-beta&tabs=http


6
https://login.microsoftonline.com/te/<tenant_id>/<policy_id>/oauth2/v2.0/authorize?client_id=<client_id>... 这个网址是正确的,但是您不应该使用Application Registration Portal创建Azure AD B2C应用程序,否则这将使它变成故障的应用程序,并且您将收到The client id ... specified in the request is not registered in tenant ...错误信息。
应使用Azure门户中的Azure AD B2C菜单创建Azure AD B2C应用程序。

1
你只需要在应用设置的API权限菜单下为组织授予管理员同意即可。对我来说,它立即生效了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接