问题
I am building a C# windows service that needs to connect to the Microsoft Dynamics CRM Web API. I am using the example code from github "A .NET 4.5 daemon application that uses a certificate to authenticate with Azure AD and get OAuth 2.0 access tokens, Github".
I am able to retrieve an access token from AAD, however, when I call the Dynamics CRM resource i get the following error:
HTTP Error 401 - Unauthorized: Access is denied
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1,
WWW-Authenticate: Bearer error=invalid_token, error_description=Error during token validation!,
I have also tried using client id and client key, but I get the same error.
Any help would be highly appreciated. Thank you very much.
来源:https://stackoverflow.com/questions/36171276/dynamics-crm-online-2016-daemon-server-application-azure-ad-authentication-e