Hello,
I've got an issue with a small script I'm trying to run to query the API with a python script.
I've registered the app on Azure, gives the permission, created an application user, assigned him a clone of the admin rights but I always get a 401 error returned.. no idea why..
Here is my code:
context = adal.AuthenticationContext('login.microsoftonline.com'+ directoryid)
tokenresponse = context.acquire_token_with_client_credentials('orgname.crm4.dynamics.com', appid, appkey)
print(tokenresponse)
accesstoken = tokenresponse.get('accessToken')
crmrequestheaders = {
'Authorization': 'Bearer ' + accesstoken,
'OData-MaxVersion': '4.0',
'OData-Version': '4.0',
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8',
'Prefer': 'odata.maxpagesize=500',
'Prefer': 'odata.include-annotations=OData.Community.Display.V1.FormattedValue'
}
crmres = requests.get(crmwebapi+ "/accounts?$select=accountid&$filter=name eq '000'", headers=crmrequestheaders)
I then get a 401 error returned while I get a 'valid' token returned... this is very weird..
ANyone had the same issue?
Thanks