2017-08-14 109 views
0

Node.js腳本使用adal-node,我試圖檢索this official documentation部分的組對話。Microsoft Graph API:獲取組對話時出現「403禁止」錯誤

我創建了一個應用程序在Azure的AD管理我的房客,並臨時檢查圖形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 /禁止錯誤(沒有在任何response.headers進一步詳細)。

請注意,當我嘗試使用我的租戶管理員帳戶從online Graph API Explorer執行相同的確切呼叫時,它會按預期工作。

+0

也許有關? https://stackoverflow.com/questions/34767672/issue-with-getting-groups-conversation –

回答

1

AFAIK,正如@Marek Rycharski在該帖子中所說,羣組對話訪問在應用程序專用授權流程中不受支持。

在我的測試中,我使用的客戶機憑證流獲取應用程序只令牌用於Microsoft圖表,所不同的是我的客戶端證書是口令,和接入令牌包括Group.ReadWrite.All應用許可,執行/v1.0/groups/{group-ID}/conversations操作,則響應示出了當403禁止的錯誤。但是使用授權代碼流來獲取具有委託權限的訪問令牌,列表會話操作正常。