2017-06-14 89 views
0

我試圖將Microsoft Graph API與App Authentication配合使用將Office365許可證分配給新創建的用戶。我的應用程序具有應用程序權限「Directory.Read.All」和「User.ReadWrite.All」。我可以成功創建(POST/users)和刪除(DELETE/users/$ id)用戶,並且我可以獲得訂閱列表(GET/subscribedSkus)。但是,如果我嘗試分配的許可證,獲得帶有403響應:圖API API assignLicense:沒有足夠的權限來完成操作

https://graph.microsoft.com/v1.0/users/ $ UPN/assignLicense

{ 
    "error": { 
    "code": "Authorization_RequestDenied", 
    "message": "Insufficient privileges to complete the operation.", 
    "innerError": { 
     "request-id": "...", 
     "date": "..." 
    } 
    } 

但是根據Graph API documentation應用程序許可「User.ReadWrite.All」應該是sufficent 。我請求體看起來如下:

{ 
    "addLicenses": [ 
    { 
     "disabledPlans": [], 
     "skuId": "..." 
    } 
    ], 
    "removeLicenses": [] 
} 

任何想法,爲什麼「User.ReadWrite.All」任何權限不sufficent,儘管圖形API文檔,否則說?

+0

看來您必須爲應用程序對象分配管理員角色(例如全局管理員或用戶帳戶管理員)。我還沒有測試過。 – phatoni

+1

它可以與Directory.ReadWrite.All一起使用嗎?因爲這是在這裏提到的唯一權限https://developer.microsoft.com/en-us/graph/docs/concepts/permissions_reference,它允許您管理許可證......所以也許在assignLicense文檔中有一個錯誤,或在API本身... – andresm53

+0

好點,我會嘗試Directory.ReadWrite.All。我只想提供所需的最小權限集合,因此使用User.ReadWrite.All,但由於我即將分配全局管理員角色,因此無關緊要。 – phatoni

回答

0

我現在可以確認assignLicense如果Directory.ReadWrite.All權限授予應用程序工作。 User.ReadWrite.All權限不足以執行assignLicense。

相關問題