简体   繁体   English

从OAuth到Microsoft Dynamics Marketing OData提要

[英]OAuth to Microsoft Dynamics Marketing OData Feed

I'm trying to connect to Microsoft Dynamics Marketing OData Data Service. 我正在尝试连接到Microsoft Dynamics营销OData数据服务。 This page lists the OData feeds for ready-only access, but does not have any information about how to authenticate against it. 该页面列出了仅准备就绪访问的OData提要,但没有有关如何对其进行身份验证的任何信息。

I have been trying to acquire an Access Token using Microsoft.IdentityModel.Clients.ActiveDirectory -Version 1.0.4 like this: 我一直在尝试使用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;

The domainName is like contoso.onmicrosoft.com but I do not know what to use for the clientId , redirectUri , resource . domainName类似于contoso.onmicrosoft.com但我不知道将什么用于clientIdredirectUriresource

I have tried many different combinations and have had errors such as: 我尝试了许多不同的组合,并遇到了诸如以下的错误:

invalid_request: AADSTS90027: The client 'xxxxxxxx-9068-486b-bdd2-dac26b8a5a7a' and resource 'Microsoft.DynamicsMarketing' identify the same application.

and

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.

I think I am close with this. 我想我对此很满意。 I have registered an application in Azure AD as a Native Client App and used its clientId and redirectUri with Microsoft.DynamicsMarketing as the resource. 我已经在Azure AD中将应用程序注册为本机客户端应用程序,并使用其clientIdredirectUriMicrosoft.DynamicsMarketing作为资源。 I found this from the Service Principal listing, Get-MsolServicePrincipal using the "Windows Azure Active Directory Module for Windows PowerShell". 我使用“用于Windows PowerShell的Windows Azure Active Directory模块”在服务主体列表Get-MsolServicePrincipal找到了这一点。

Are these the correct parameters and I just need to sort out permission some how or am I way off? 这些是正确的参数吗?我只需要对许可进行一些整理,或者我应该如何处理?

Update The correct resource is https://marketing-infra.dynamics.com/ which is one of the service principal names listed as is the previous one I used Microsoft.DynamicsMarketing . 更新正确的resourcehttps://marketing-infra.dynamics.com/ ,它是列出的服务主体名称之一,与我以前使用的Microsoft.DynamicsMarketing This works with the clientId and redirectUri that I captured from Fiddler from Power Query. 这与我从Power Query从Fiddler捕获的clientIdredirectUri一起使用。 I am pretty certain that to get it working with my clientId I need to give Dynamics Marketing permissions in the Azure Application Registration, "permissions to other applications". 我非常确定,要使其与我的clientId一起使用,我需要在Azure应用程序注册中为Dynamics Marketing授予权限,即“对其他应用程序的许可”。 The problem is Dynamics Marketing is not an application that is available to add and the Dynamics CRM delegate permissions does not have a role for Dynamics Marketing. 问题是Dynamics Marketing不是可添加的应用程序,并且Dynamics CRM委托权限没有对Dynamics Marketing起作用。

It indeed is possible to access the feeds. 确实可以访问提要。 But you have to register an application in Azure Active Directory and authorize that to access Dynamics Marketing. 但是您必须在Azure Active Directory中注册一个应用程序,并授权该应用程序访问Dynamics Marketing。

Please look at my BlogPost on this topic here - includes steps and sample code :-) 请在此处查看有关此主题的我的BlogPost-包括步骤和示例代码:-)

I have also published PowerShell cmdlets on GitHub that do this is a more generic way and do not use a proxy class for the data model. 我还在GitHub上发布了PowerShell cmdlet,这样做是一种更通用的方法,并且不对数据模型使用代理类。 PowerShell cmdlets to access to MDM across OData and SDK PowerShell cmdlet通过OData和SDK访问MDM

I got the answer from Microsoft that clients other then Power Query are not supported. 我从Microsoft得到的答案是,不支持Power Query以外的其他客户端。 So the code I have above is correct and there is not yet support for adding permission to access it with other applications. 因此,我上面的代码是正确的,尚不支持添加使用其他应用程序对其进行访问的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM