Giter Club home page Giter Club logo

Comments (6)

bshaffer avatar bshaffer commented on August 9, 2024 1

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

#5842 (comment)

from google-cloud-php.

erensertkaya avatar erensertkaya commented on August 9, 2024 1

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"),
             '[email protected]'
         ));
        // 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());
        }
    }

from google-cloud-php.

wisely11 avatar wisely11 commented on August 9, 2024 1

Whats the "Other related configurations on google cloud console" configurations you did @erensertkaya ?

from google-cloud-php.

erensertkaya avatar erensertkaya commented on August 9, 2024

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

from google-cloud-php.

erensertkaya avatar erensertkaya commented on August 9, 2024

@ajupazhamayil

from google-cloud-php.

erensertkaya avatar erensertkaya commented on August 9, 2024

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('[email protected]');
         $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());
        }
    }

from google-cloud-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.