【发布时间】:2014-07-24 06:36:35
【问题描述】:
我正在尝试连接到 Microsoft Dynamics Marketing OData 数据服务。 This page 列出 OData 提要以供仅访问,但没有任何关于如何对其进行身份验证的信息。
我一直在尝试使用 Microsoft.IdentityModel.Clients.ActiveDirectory -Version 1.0.4 获取访问令牌,如下所示:
var authenticationContext = new AuthenticationContext("https://login.windows.net/" + domainName);
var authenticationResult = authenticationContext.AcquireToken(resource, clientId, redirectUri);
var token = authenticationResult.AccessToken;
domainName 类似于contoso.onmicrosoft.com,但我不知道clientId、redirectUri、resource 的用途。
我尝试了许多不同的组合,但出现以下错误:
invalid_request: AADSTS90027: The client 'xxxxxxxx-9068-486b-bdd2-dac26b8a5a7a' and resource 'Microsoft.DynamicsMarketing' identify the same application.
和
access_denied: AADSTS65005: The client application has requested access to resource 'Microsoft.DynamicsMarketing'. This request has failed because the client has not specified this resource in its requiredResourceAccess list.
我想我很接近这一点。我在 Azure AD 中注册了一个应用程序作为本机客户端应用程序,并将其 clientId 和 redirectUri 与 Microsoft.DynamicsMarketing 用作资源。我使用“Windows Azure Active Directory Module for Windows PowerShell”从服务主体列表Get-MsolServicePrincipal 中找到了这个。
这些参数是否正确,我只需要整理一下权限,或者我该怎么做?
更新
正确的resource 是https://marketing-infra.dynamics.com/,它是列出的服务主体名称之一,与我之前使用的Microsoft.DynamicsMarketing 一样。这适用于我从 Power Query 的 Fiddler 捕获的 clientId 和 redirectUri。我很确定要让它与我的 clientId 一起工作,我需要在 Azure 应用程序注册中授予 Dynamics Marketing 权限,即“对其他应用程序的权限”。问题是 Dynamics Marketing 不是可添加的应用程序,Dynamics CRM 委托权限没有 Dynamics Marketing 的角色。
【问题讨论】:
-
您能分享一下您对此问题的解决方案吗?
标签: c# oauth odata dynamics-crm-online azure-active-directory