在使用adal-node的Node.js脚本中,我试图按照本官方文档的部分内容检索群组对话。
我在Azure AD 管理中为我的租户创建了一个应用程序,并临时检查了Graph API 的所有权限(应该排除“缺少权限”问题),然后单击“授予权限”按钮。
我正在使用证书进行身份验证。
基本上我在做:
var adal = require('adal-node');
var authorityUrl = 'https://login.windows.net/{my-tenant}';
var context = new adal.AuthenticationContext(authorityUrl);
context.acquireTokenWithClientCertificate(
'https://graph.microsoft.com',
'{my-app/client-ID}',
'{certificate file content}',
'{certificate thumbprint}',
function(err, tokenResponse) {
// this method does an HTTPS call with autorization token & returns results (uses 'https.request()')
callRestApi(
'graph.microsoft.com', // host
443, // port
'/v1.0/groups/{group-ID}/threads', // path
'GET', // method
tokenResponse.accessToken, // token
function(err, results) {
console.log(err);
console.log(results);
});
});
例如,当我使用/v1.0/groups/{group-ID}/description
作为路径时,它会按预期工作。
但是,使用/v1.0/groups/{group-ID}/conversations
或/v1.0/groups/{group-ID}/threads
,我总是收到HTTP 403 / Forbidden错误(在 response.headers 中没有任何进一步的细节)。
请注意,当我尝试使用租户管理员帐户从在线 Graph API Explorer执行完全相同的调用时,它按预期工作。
AFAIK,正如@Marek Rycharski 在线程中所说,仅应用程序授权流程不支持群组对话访问。
在我的测试中,我使用客户端凭据流获取 microsoft graph 的仅应用程序令牌,不同之处在于我的客户端凭据是密码,访问令牌包括Group.ReadWrite.All
应用程序权限,执行/v1.0/groups/{group-ID}/conversations
操作时,响应显示 403 Forbidden error 。但是使用授权代码流获取具有委托权限的访问令牌,列表对话操作工作正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句