angular - 如何在 Azure AD 上注册单租户 SPA?
问题描述
我创建了一个新的 Angular 项目并设置了 MSAL ( @azure/msal-angular
)。
当我转到 MsalGuarded 路由时,它会正确重定向我以登录。但是,在提供我的凭据后,我收到一条错误消息:
We're unable to complete your request
unauthorized_client: The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https://go.microsoft.com/fwlink/?linkid=2083908.
在 Azure 门户上,我使用重定向 URI http://localhost:4200 注册了一个 SPA、单租户,因为我不想为消费者启用它。
我尝试启用/禁用隐式授权,但没有帮助(无论如何都不应该为 OAuth2/OpenID Connect 启用)
我的问题是:是否可以注册单租户 SPA?还是单租户只与私人客户合作?
解决方案
这取决于您是否要将 spa 应用程序公开给其他帐户。如果使用https://login.microsoftonline.com/common/
,则表示它接受任何帐户,然后您需要选择我的应用程序,然后转到Authentication选项卡,然后在Supported account types下,选择Accounts in any organizations directory (Any Azure AD directory - Multitenant)。
如果你想将spa应用限制在这个租户内,即不公开给其他租户,你可以尝试https://login.microsoftonline.com/tenant id/
或者https://login.microsoftonline.com/organizations/
登录。