Google Meet REST API 资源空间权限被拒绝(或者可能不存在)错误

问题描述 投票:0回答:1

我刚刚在谷歌云控制台中配置了所有内容,我使用服务帐户作为身份验证方法,并将密钥文件下载为 json。但我收到这个错误

"Call failed with message: { "message": "Permission denied on resource Space (or it might not exist)", "code": 7, "status": "PERMISSION_DENIED", "details": [] }"

<?php

namespace App\Http\Controllers\Panel;

use App\Http\Controllers\Controller;
use Google\ApiCore\ApiException;
use Google\ApiCore\ValidationException;
use Google\Apps\Meet\V2\Client\SpacesServiceClient;
use Google\Apps\Meet\V2\CreateSpaceRequest;
use Google\Apps\Meet\V2\Space;

class YourControllerName extends Controller
{
    public function __construct()
    {

    }

    /**
     * @throws ValidationException
     */
    public function index()
    {
        $spacesServiceClient  = new SpacesServiceClient([
            'credentials' => storage_path('app\google-calendar\credentials.json')
        ]);

        $request = new CreateSpaceRequest();

        try {
            $response = $spacesServiceClient->createSpace($request);
            printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
        } catch (ApiException $ex) {
            printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
        }
    
php google-cloud-platform google-api google-api-php-client
1个回答
0
投票

从凭据开始不是文件的路径。 Credentials 是凭证对象

const CREDENTIALS = 'workspaceserviceaccount.json';
const SCOPES = ['https://www.googleapis.com/auth/chat.spaces];   // scope must be configured in workspace.   
const DOMAIN_ADMIN = "[email protected]"


// Create service account client, with scopes, and delegate to user on domain.
$client = new Google\Client();
$client->setAuthConfig(CREDENTIALS);
$client->setScopes(SCOPES);
$client->setSubject(DOMAIN_ADMIN );

这就是您将要传递给的

$spacesServiceClient  = new SpacesServiceClient($client);
© www.soinside.com 2019 - 2024. All rights reserved.