首页 文章

Microsoft Graph API:获取群组对话时出现“403 forbidden”错误

提问于
浏览
0

在使用adal-nodeNode.js 脚本中,我正在尝试检索this official documentation部分之后的组对话 .

我在 Azure AD administration 为我的租户创建了一个应用程序,并暂时检查了 Graph API 的所有权限(应排除"missing permission"问题),然后单击“ Grant permissions ”按钮 .

我正在使用证书进行身份验证 .

基本上我在做:

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中没有任何进一步的细节) .

请注意,当我尝试使用我的租户管理员帐户从online Graph API Explorer执行相同的确切调用时,它会按预期工作 .

1 回答

  • 1

    正如@Marek Rycharski所说,AFAIK在专线授权流程中不支持群组对话访问 .

    在我的测试中,我使用客户端凭证流来获取微软图的app-only令牌,区别在于我的客户端凭证是密码,而访问令牌包含 Group.ReadWrite.All 应用程序权限,当执行 /v1.0/groups/{group-ID}/conversations 操作时,响应显示403 Forbidden错误 . 但是使用授权代码流来获取具有委托权限的访问令牌,列表对话操作正常 .

相关问题