azure-active-directory - Azure Active Directory v2.0守护程序和服务器端应用程序支持

标签 azure-active-directory msal

试图弄清楚当前的v2.0端点是否支持守护程序和服务器端应用程序流。
本文讨论以下流程:https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-flows
它指出:

This article describes the types of apps that you can build by using Azure AD v2.0, regardless of your preferred language or platform. The information in this article is designed to help you understand high-level scenarios before you start working with the code.


此外,它指出:

Currently, the types of apps in this section are not supported by the v2.0 endpoint, but they are on the roadmap for future development. For additional limitations and restrictions for the v2.0 endpoint


最后,我尝试构建一个连接到Graph API的应用程序,该应用程序将按计划通过“凭据”连接到Graph API,从而允许它代表允许其访问的用户访问API。
在测试工具中,我可以使用以下方法获取 token :
var pca = new PublicClientApplication(connector.AzureClientId)
          {
             RedirectUri = redirectUrl
          };
var result = await pca.AcquireTokenAsync(new[] {"Directory.Read.All"},
                (Microsoft.Identity.Client.User) null, UiOptions.ForceLogin, string.Empty);
在相同的工具中,我无法使用以下方式获得 token :
var cca = new ConfidentialClientApplication(
                connector.AzureClientId,
                redirectUrl,
                new ClientCredential(connector.AzureClientSecretKey),
                null) {PlatformParameters = new PlatformParameters()};

var result = await cca.AcquireTokenForClient(new[] { "Directory.Read.All" }, string.Empty);
这将导致:

Exception thrown: 'Microsoft.Identity.Client.MsalServiceException' in mscorlib.dll

Additional information: AADSTS70011: The provided value for the input parameter 'scope' is not valid. The scope Directory.Read.All is not valid. Trace ID: dcba6878-5908-44a0-95f3-c51b0b4f1a00 Correlation ID: 1612e41a-a283-4557-b462-09653d7e4c21 Timestamp: 2017-04-10 20:53:05Z


自2016年4月16日以来,尚未更新MSAL软件包Microsoft.Identity.Client(1.0.304142221-alpha)。这甚至是我应该使用的软件包吗?

最佳答案

当将客户端凭据流与Azure AD V2.0一起使用时,为此请求中scope参数传递的值应该是所需资源的资源标识符(应用程序ID URI),并带有.default后缀。对于Microsoft Graph示例,该值为https://graph.microsoft.com/.default

请单击here了解更多详细信息。 here是将客户端凭据流与Azure AD V2.0终结点一起使用的教程。

关于azure-active-directory - Azure Active Directory v2.0守护程序和服务器端应用程序支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43332770/

相关文章:

c# - AAD 缺少权限

azure - 为什么作为订阅的共同管理员我无法编辑 Active Directory?

azure-active-directory - MSAL 可以在我自己的权限下使用吗(例如 IdentityServer)

asp.net - 如何使现有的具有简单登录(用户名和密码)的 Web 应用程序与 Azure AD 单点登录兼容?

azure - ADWtest 需要访问组织中只有管理员才能授予的资源的权限

azure - 当主租户中的帐户被删除时, guest 租户中的 Azure AD guest 帐户会发生什么情况?

.net - 注销后 Angular MSAL 重定向到 Microsoft 登录

azure-active-directory - 如何为个人 Microsoft 帐户 (MSA) 实现代表 (OBO) 流程?

ios - 将 kAuthority 更改为消费者不起作用

c# - 使用无人参与的 C# 控制台验证 Office 365 IMAP 帐户