[英]OAuth to Microsoft Dynamics Marketing OData Feed
我正在尝试连接到Microsoft Dynamics营销OData数据服务。 该页面列出了仅准备就绪访问的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 PowerShell的Windows Azure Active Directory模块”在服务主体列表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起作用。
确实可以访问提要。 但是您必须在Azure Active Directory中注册一个应用程序,并授权该应用程序访问Dynamics Marketing。
请在此处查看有关此主题的我的BlogPost-包括步骤和示例代码:-)
我还在GitHub上发布了PowerShell cmdlet,这样做是一种更通用的方法,并且不对数据模型使用代理类。 PowerShell cmdlet通过OData和SDK访问MDM
我从Microsoft得到的答案是,不支持Power Query以外的其他客户端。 因此,我上面的代码是正确的,尚不支持添加使用其他应用程序对其进行访问的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.