php Ms graph API,使用的查询预订API不起作用

6vl6ewon  于 2023-09-29  发布在  PHP
关注(0)|答案(1)|浏览(110)

我面临着一些挑战,而与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

uelo1irk

uelo1irk1#

尝试授予应用程序权限BookingsAppointment.ReadWrite.AllBookings.Read.All的管理员许可。
但根据医生的说法
List bookingBusinesses-不支持应用程序权限
获取bookingBusiness -支持应用权限
授予管理员同意后,尝试两个端点

GET /solutions/bookingBusinesses
GET /solutions/bookingBusinesses/{id}

相关问题