我面临着一些挑战,而与MS图形API的工作,特别是与预订一。错误如下GET https://graph.microsoft.com/v1.0/solutions/bookingBusinesses
导致401 Unauthorized
响应:{“error”:{“code”:“InvalidAuthenticationToken”,“message”:“访问令牌验证失败。",“innerError”:{“date”:“2023-09-22T06:36:11”,“request-id”:“5d73f58d-9297-4ca8-bfe6-bafee1ebc54b”,“client-request-id”:“5d73f58d-9297-4ca8-bfe6-bafee1ebc54b”}
到目前为止我做的代码是
public function listAppoinment($userPrincipalName){
$this->graph->setAccessToken($this->grant_type_password());
$event = $this->graph->createRequest("GET", "/solutions/bookingBusinesses")
->execute();
}
private function grant_type_password(){
$configuration = [
'form_params' => [
'client_id' => $this->clientId,
'client_secret' => $this->clientSecret,
'grant_type' => 'password',
'scope' => "api://$this->clientId/Userlogin",
'username' => 'myMailid',
'password' =>'password'
],
'http_errors' => false,
'curl' => [
CURLOPT_FAILONERROR => false
],
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded'
]
];
$guzzle = new Client();
$url = 'https://login.microsoftonline.com/' . $this->tenentId . '/oauth2/v2.0/token';
$response = $guzzle->post($url, $configuration);
$responseBody = json_decode($response->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR);
if ($response->getStatusCode() !== 200) {
$error = $responseBody->error ?? $response->getStatusCode();
trigger_error($responseBody->error_description ?? $error, E_USER_ERROR);
}
return $responseBody->access_token;
}
和给予的权限x1c 0d1x
1条答案
按热度按时间uelo1irk1#
尝试授予应用程序权限
BookingsAppointment.ReadWrite.All
和Bookings.Read.All
的管理员许可。但根据医生的说法
List bookingBusinesses-不支持应用程序权限
获取bookingBusiness -支持应用权限
授予管理员同意后,尝试两个端点