C# OAuth到Microsoft Dynamics营销OData提要
我正在尝试连接到Microsoft Dynamics Marketing OData数据服务。列出仅用于就绪访问的OData源,但没有关于如何对其进行身份验证的任何信息 我一直在尝试使用Microsoft.IdentityModel.Clients.ActiveDirectory(版本1.0.4)获取访问令牌,如下所示:C# OAuth到Microsoft Dynamics营销OData提要,c#,oauth,odata,dynamics-crm-online,azure-active-directory,C#,Oauth,Odata,Dynamics Crm Online,Azure Active Directory,我正在尝试连接到Microsoft Dynamics Marketing OData数据服务。列出仅用于就绪访问的OData源,但没有关于如何对其进行身份验证的任何信息 我一直在尝试使用Microsoft.IdentityModel.Clients.ActiveDirectory(版本1.0.4)获取访问令牌,如下所示: var authenticationContext = new AuthenticationContext("https://login.windows.net/" + dom
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
,重定向URI
,资源使用什么
我尝试了许多不同的组合,并出现了以下错误:
invalid_request: AADSTS90027: The client 'xxxxxxxx-9068-486b-bdd2-dac26b8a5a7a' and resource 'Microsoft.DynamicsMarketing' identify the same application.
及
我想我已经接近这一点了。我已在Azure AD中注册了一个应用程序作为本机客户端应用程序,并将其客户端ID
和重定向URI
与Microsoft.DynamicsMarketing
一起用作资源。我从服务主体列表中找到了这一点,即使用“Windows PowerShell的Windows Azure Active Directory模块”获取MsolServicePrincipal
这些是正确的参数吗?我只需要整理一下,我是怎么走的
更新
正确的
资源是https://marketing-infra.dynamics.com/
这是列出的服务主体名称之一,与我以前使用的Microsoft.DynamicsMarketing
相同。这适用于我从Power Query的Fiddler中捕获的clientId
和redirectUri
。我非常确定,为了让它与我的clientId一起工作,我需要在Azure应用程序注册“其他应用程序的权限”中授予Dynamics Marketing权限。问题是Dynamics Marketing不是一个可添加的应用程序,Dynamics CRM委派权限不具有Dynamics Marketing的角色。我从Microsoft得到的答案是,不支持Power Query以外的客户端。因此,我上面的代码是正确的,目前还不支持通过其他应用程序添加访问权限。确实可以访问提要。但您必须在Azure Active Directory中注册一个应用程序并授权该应用程序才能访问Dynamics Marketing
请查看我的-包括步骤和示例代码:-)
我还在GitHub上发布了PowerShell cmdlet,这种方法更通用,并且不为数据模型使用代理类。
您能分享一下这个问题的解决方案吗?不过,您可以在回答中包含一个示例代码。
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.