我正在使用密码授权类型在IFD上整合与Dynamics CRM onfrontise(v8.1 / 8.2)的api集成 .
我正在成功检索访问令牌,但是当我尝试调用 endpoints 时(例如/api/data/v8.2/contacts?$select=fullname,contactid)我得到401 - 访问被拒绝错误 . 当我与用户登录CRM时,我可以成功查看此数据,并在所有测试的 endpoints 上发生错误 .
有趣的是,今天早上我意识到检索到的令牌不能被base64解码 - 这是正确的吗?
我可以使用一些想法来解决问题 . 我采取的步骤:
-
三重检查初始令牌请求
-
Triple检查了服务根URL
-
尝试了两种CRM / Azure设置
-
尝试使用我自己的(节点)代码和互联网示例
-
各种令牌设置
-
确认用户存在于Azure和CRM中
-
已确认的用户具有足够的权限
-
确认Azure上的应用程序已授予所有动态权限
-
确认我与Azure和CRM在同一网络上
很明显,我在Azure或CRM中的某处存在配置问题 . 但是,我找不到任何指南或问题,建议查看我尚未检查的问题,我可以真正使用那些不得不在模糊设置中进行调整的人的输入等 .
继承了我的令牌请求:
var options = {
method: 'POST',
url: 'https://login.microsoftonline.com/<snip>/oauth2/token', //for 'intercity technology' (guid is unique)
headers:
{
'cache-control': 'no-cache',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' },
formData:
{
grant_type: 'password',
client_id: ‘<snip>’, //aplication id
client_secret: ‘<snip>’, //any key in the keys list
username: ‘<snip>’,
password: ‘<snip>’, // and their password
resource: ‘<snip>’ //application id
}
};
logger.debug(util.inspect(options));
request(options, function (error, response, body) {
...
继承了我目前的api请求测试:
var options = {
method: 'GET',
url: organisation_url + '/api/data/v8.2/contacts?$select=fullname,contactid',
headers: {
Authorization: 'Bearer '+token,
Accept: 'application/json',
'OData-MaxVersion':4.0,
'OData-Version': 4.0,
'Content-Type': 'application/json; charset=utf-8',
'Prefer': 'odata.maxpagesize=500',
'Prefer': 'odata.include-annotations=OData.Community.Display.V1.FormattedValue'
}
};
logger.debug(util.inspect(options));
request(options, function (error, response, body) {
...
1 回答
您需要使用授权类型'client_credentials'而不是'password',因为后者不受支持 . 就像是:
按照指南here和所有链接确保正确注册AAD应用程序并且CRM应用程序用户已就位 .