I am getting a 403 when I try to manage entities in the Field Service app via API.
I am getting a token like so:
authority_url = "">login.microsoftonline.com/<my_tenant>"
client_id = '<client_id>'
client_secret = '<client_secret>'
resource = 'https://<my_org>.crm.dynamics.com'
context = AuthenticationContext(authority_url, validate_authority=None, cache=None, api_version=None, timeout=None, enable_pii=False)
token = context.acquire_token_with_client_credentials(resource, client_id, client_secret)
return token['accessToken']
I am trying to hit the “WhoAmI” endpoint indicated here: docs.microsoft.com/.../gg334767(v=crm.8)
url = 'https://<my_org>.crm.dynamics.com/api/data/v9.0/WhoAmI'
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer {0}'.format(token)} # token from the previous call above.
r = requests.get(url, headers=headers)
At this point I get an HTTP response of 403.
It looks like I get authenticated correctly, but I am not getting authorized. How would I go about fixing this? Does my code look correct?
I gave my registered app permission to "Dynamics CRM". But that didn't work.
Any advice?