AlexaCRM / dynamics-webapi-toolkit

Dynamics 365 Web API Toolkit for PHP
MIT License
75 stars 58 forks source link

403 code while fetching record #49

Closed CaptainCannabis closed 3 years ago

CaptainCannabis commented 3 years ago

Not realy a bug report.

I am getting the Message: Metadata request returned a 403 code while fetching record. Can you please suggest what am i missing ? I am connecting with crm like below with my dynamic credentials -

I did everything stated here:

https://docs.microsoft.com/de-DE/powerapps/developer/data-platform/walkthrough-register-app-azure-active-directory

I guess its a problem with my azure/dynamics config. If i try to connect by using fetchxmlbuilder i can choose the method "client id / secret". If i put my dynamics organization url in and the app-id & key it fails and tries to switch to outh. If i enter my credentials (email and password) oauth login works and i can fetch data from the api.

I got a developer account from ms developer program, sales Professional and all that stuff.

What could be wrong in my setup?

Its hard to get any support by official contacts so sorry for spaming in your issues!

georged commented 3 years ago

If you can't connect with client id/secret from xrmtoolbox, that's a good indication that it's a configuration issue.

Couple questions that I asked the other poster.

Thanks

CaptainCannabis commented 3 years ago

What exactly do you mean with "app user". I got some active directory users. For those i added licenses for dynamics. These users got roles like "Sales Professional Person" or "System Administrator". When evertything regarding sales professional worked in browser i set up an application in azure. Generated a token for that application and set the permissions for that application like mentioned everywhere.

That way i get an url, application and token. I thought thats the three things i need for authentication. If i log in with xrmtoolbox and choose "client id/ key" there is no need for a user. A user (with mail an password) would be used by logging in via oauth, or am i wrong?

EDIT:

do you have an app user set up in the instance does this user have the role assigned

Your are talking about this, aren't you? https://docs.microsoft.com/en-us/power-platform/admin/database-security#create-or-configure-a-custom-security-role

EDIT 2:

For everyone who will stumble over this. You need to set up an application and security token in ms azure, After that you have to switch to your dynamics webspace/instance and go to the list view for application users. Follow the tutorial. The non interactive user is linked to the application id of the azure app - that ensures that the login by client id and security code works.

https://coombes.nz/blog/adding-service-user-to-dynamics-365/

georged commented 3 years ago

@CaptainCannabis

this is documented as part of Getting Started:

Next step is to create an application user in CRM. Go to the Admin center, navigate to your environment’s Settings / Users. Switch to the Application Users view, hit New, switch to the “Application User” form, as can be seen here. Fill in the Application ID which you saved before, as well as Full Name and Primary Email fields, then save the user. Associate the user with relevant security roles, for example “System Administrator” and “Delegate”. Feel free to create custom security roles which suit your use case best.

You can follow step by step instructions in the official Microsoft docs.