Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppsMeet Package Permission denied on resource Space error #7257

Closed
erensertkaya opened this issue Apr 25, 2024 · 5 comments
Closed

AppsMeet Package Permission denied on resource Space error #7257

erensertkaya opened this issue Apr 25, 2024 · 5 comments

Comments

@erensertkaya
Copy link

erensertkaya commented Apr 25, 2024

Environment details

  • OS: Microsoft 10 Xampp
  • PHP version: 8.0
  • Package name and version: AppsMeet 0.2.1

Steps to reproduce

  1. I have just configured everything in google cloud console, i am using service account as auth method and i download key file as json. But i am getting this error
    "Call failed with message: { "message": "Permission denied on resource Space (or it might not exist)", "code": 7, "status": "PERMISSION_DENIED", "details": [] }"

Code example

 public function index()
    {
        $spacesServiceClient  = new SpacesServiceClient([
            'credentials' => storage_path('app\google-calendar\key.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());
        }
    }
@erensertkaya
Copy link
Author

Anyone can help, i tried adding domain wide delegation with specified oauth scopes which stated in documentation but i am still getting same error ?

@erensertkaya
Copy link
Author

@ajupazhamayil

@erensertkaya
Copy link
Author

For adding using domain wide delegation i updated my code to this which is for impersonate my main user from service account but it's not working since SpacesServiceClient not accepting Client object but $options i started to think that this package not allowing you impersonate yet.

    public function index(){
         putenv('GOOGLE_APPLICATION_CREDENTIALS=' . base_path("key.json"));

         $client = new Client();
         $client->useApplicationDefaultCredentials();
         $client->addScope('https://www.googleapis.com/auth/meetings.space.readonly');
         $client->addScope('https://www.googleapis.com/auth/meetings.space.created');
         $client->setSubject('test@test.com');
         $options = [
             'credentials' => $client,
         ];

        // Create a client.
        $spacesServiceClient = new SpacesServiceClient($options);

        // Prepare the request message.
        $request = new CreateSpaceRequest();

        // Call the API and handle any network failures.
        try {
            /** @var Space $response */
            $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());
        }
    }

@bshaffer
Copy link
Contributor

See this comment for how to set the subject (e.g. enable domain-wide delegation)

#5842 (comment)

@erensertkaya
Copy link
Author

erensertkaya commented Apr 29, 2024

after setting up domain wide delegation and other related configurations on google cloud console this code worked for me

public function index(){
         $credentials = (new ServiceAccountCredentials(['https://www.googleapis.com/auth/meetings.space.readonly','https://www.googleapis.com/auth/meetings.space.created']
             ,base_path("key.json"),
             'test@test.com'
         ));
        // Create a client.
        $spacesServiceClient = new SpacesServiceClient(['credentials' => $credentials]);

        // Prepare the request message.
        $request = new CreateSpaceRequest();

        // Call the API and handle any network failures.
        try {
            /** @var Space $response */
            $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());
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants