Closed claudiobat closed 3 months ago
Hi, I'd like to get the list of the users of the domain using "google-api-php-client". As SuperAdmin on the Google backend I have:
However, when executing the "listUsers" method I have the error:
{ "error": { "code": 403, "message": "Not Authorized to access this resource/api", "errors": [ { "message": "Not Authorized to access this resource/api", "domain": "global", "reason": "forbidden" } ] } }
This is the code I'm using:
` $serviceAccountPath = base_path().'/config_google.json'; $credentials = json_decode(file_get_contents($serviceAccountPath), true);
$this->client = new Client(); $this->client->setApplicationName('Google Workspace Directory API'); $this->client->setAuthConfig($credentials); $this->client->setScopes([ 'https://www.googleapis.com/auth/admin.directory.domain', 'https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.group', ]); $service = new Directory($this->client); $users = $service->users->listUsers([ 'domain' => 'mydomain.com', ]);
` What could be the problem? How can I solve it? Thank you very much
Claudio
Hi all, I've solved specifying the "sub" parameter in the request.
claudio
Hi, I'd like to get the list of the users of the domain using "google-api-php-client". As SuperAdmin on the Google backend I have:
However, when executing the "listUsers" method I have the error:
{ "error": { "code": 403, "message": "Not Authorized to access this resource/api", "errors": [ { "message": "Not Authorized to access this resource/api", "domain": "global", "reason": "forbidden" } ] } }
This is the code I'm using:
` $serviceAccountPath = base_path().'/config_google.json'; $credentials = json_decode(file_get_contents($serviceAccountPath), true);
` What could be the problem? How can I solve it? Thank you very much
Claudio