Microsoft Graph Api显示的权限不足以完成操作

时间:2017-12-04 00:17:47

标签: azure-active-directory microsoft-graph

我有一个管理员帐户正试图通过php Curl使用microsoft Graph API更新其数据,但显示错误:

{
    "error": {
        "code": "Authorization_RequestDenied",
        "message": "Insufficient privileges to complete the operation.",
        "innerError": {
            "request-id": "110ac3f6-16d1-41a2-b2dc-add954514666",
            "date": "2017-12-04T00:12:02"
        }
    }
}

下面是更新的代码

<?php 
session_start();

echo $acc= $_SESSION['access_token'];

$data_string = array("jobTitle" => 'Fibre ngineer', "officeLocation" => "SAMOLA"); 
$data = json_encode($data_string); 
//$data = $data_string; 
$curl = curl_init();

curl_setopt_array($curl, array( 
CURLOPT_URL => "https://graph.microsoft.com/v1.0/users/@mydata.onmicrosoft.com", 
//CURLOPT_URL => "https://graph.microsoft.com/v1.0/me", 
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true, 
CURLOPT_ENCODING => "", 
CURLOPT_MAXREDIRS => 10, 
CURLOPT_TIMEOUT => 30, 
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, 
//curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
CURLOPT_CUSTOMREQUEST => "PATCH", 
CURLOPT_POSTFIELDS => "$data", 
CURLOPT_HTTPHEADER => array( 
"accept: application/json", 
"authorization: Bearer $acc", 
"content-type: application/json; charset=utf-8" 
), 
));

$response = curl_exec($curl); 
$err = curl_error($curl);

curl_close($curl);
print_r($response);
$json = json_decode($response);

if ($err) { 
echo "cURL Error #:" . $err; 
} else { 
//echo $response; 
}
?>

我还设置了所有必需的权限,例如Directory and Users read access,但无法使其正常工作

0 个答案:

没有答案