【问题标题】:OAuth to Microsoft Dynamics Marketing OData FeedOAuth 到 Microsoft Dynamics Marketing OData 源
【发布时间】: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,但我不知道clientIdredirectUriresource 的用途。

我尝试了许多不同的组合,但出现以下错误:

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 中注册了一个应用程序作为本机客户端应用程序,并将其 clientIdredirectUriMicrosoft.DynamicsMarketing 用作资源。我使用“Windows Azure Active Directory Module for Windows PowerShell”从服务主体列表Get-MsolServicePrincipal 中找到了这个。

这些参数是否正确,我只需要整理一下权限,或者我该怎么做?

更新 正确的resourcehttps://marketing-infra.dynamics.com/,它是列出的服务主体名称之一,与我之前使用的Microsoft.DynamicsMarketing 一样。这适用于我从 Power Query 的 Fiddler 捕获的 clientIdredirectUri。我很确定要让它与我的 clientId 一起工作,我需要在 Azure 应用程序注册中授予 Dynamics Marketing 权限,即“对其他应用程序的权限”。问题是 Dynamics Marketing 不是可添加的应用程序,Dynamics CRM 委托权限没有 Dynamics Marketing 的角色。

【问题讨论】:

  • 您能分享一下您对此问题的解决方案吗?

标签: c# oauth odata dynamics-crm-online azure-active-directory


【解决方案1】:

确实可以访问提要。但是您必须在 Azure Active Directory 中注册一个应用程序并授权它访问 Dynamics Marketing。

请看我的BlogPost on this topic here - 包括步骤和示例代码:-)

我还在 GitHub 上发布了 PowerShell cmdlet,这是一种更通用的方式,并且不使用数据模型的代理类。 PowerShell cmdlets to access to MDM across OData and SDK

【讨论】:

  • 不过,您可以在答案中包含示例代码。
【解决方案2】:

我从 Microsoft 得到的答复是不支持 Power Query 以外的客户端。所以我上面的代码是正确的,目前还不支持添加其他应用程序访问它的权限。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-29
    • 2017-06-19
    • 1970-01-01
    • 2018-09-22
    • 1970-01-01
    • 2023-01-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多