0

I've been trying to access the Dynamics 365 API in a Sharepoint Online Webpart for days. I have already registered the app in Azure, I also get an access token when I call the request with Client ID and Client Secret via Insomnia/Postman. Nevertheless I get a 401 Unauthorized Error all the time. When I enter the same endpoint in the browser with a logged in Office 365 user, I get the correct answer from Dynamics CRM.

I would prefer it if Sharepoint recognizes the Office 365 user and if this user has access to Dynamics CRM the content is displayed.

How would I be able to do this?

  • I think you already did this but just to make sure, after you registered your app, you did gave permission to that app? Doc for [Ref](https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/walkthrough-register-app-azure-active-directory) and Next Link for [Ref](https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/setup-postman-environment) – AnkUser Jan 15 '20 at 07:24
  • The permissions `user_impersonation` are already set. – Sebastian Müller Jan 15 '20 at 09:44
  • Then you should be able to communicate with Webapi using Postman. before moving ahead try with postman. – AnkUser Jan 16 '20 at 09:20
  • Nope, i get an auth token with the ClientID and Client Secret but https://xxx.crm4.dynamics.com/api/data/v9.1/ sends 401 Unauthorized – Sebastian Müller Jan 16 '20 at 12:41
  • hmm strange, just cross verifying, are you using same credentials as you used for creating APP, also does your user has system admin rights ? [Ref Link](https://stackoverflow.com/questions/54566738/post-get-request-from-postman-to-microsoft-dynamics-crm-365) – AnkUser Jan 16 '20 at 12:59
  • I don't use any user credentials if thats what you mean. I just send clientID and clientsecret to the endpoint https://login.microsoftonline.com/xxx/oauth2/token to get the oauth2 token. That works great, i get an auth token but when i try to get stuff from the dynamics api there is the 401 error. – Sebastian Müller Jan 16 '20 at 13:21
  • That's correct whole purpose of client ID and secret is to avoid username and password. let me try connecting one of my trail instance and see if I face the same – AnkUser Jan 16 '20 at 13:35
  • Anything new ? @AnkUser – Sebastian Müller Jan 20 '20 at 14:11

0 Answers0