修复 "domain not found" 错误是否需要 G-Suite 帐户
Does fixing a "domain not found" error require a G-Suite account
简而言之:
即使我没有 G-Suite 帐户,是否可以使用服务器端脚本将成员插入 Google 组?如果是,Domain not found
指的是什么?
更多详情
我正试图帮助一家小型非政府组织将他们管理新用户注册的部分工作自动化。特别是我正在设置一个脚本,它将在 google 组中插入新成员。
按照文档 I:
- 创建了一个服务帐户(从 https://console.developers.google.com/iam-admin/serviceaccounts )
- 启用了所需的 apis
- 运行 以下脚本使用 php 客户端 api
密码是:
<?php
require __DIR__ . '/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("GoogleGroup MA AutoUpdate");
$client->setScopes(array(
Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP
));
$user_to_impersonate = 'adminzwp@local-volt-214313.iam.gserviceaccount.com';
$client->setSubject($user_to_impersonate);
echo "Built client\n";
$service = new Google_Service_Directory($client);
$member = new Google_Service_Directory_Member();
$member->setEmail("some_test@hotmail.fr");
$member->setRole("MEMBER");
$groupEmail="myGroup@googlegroups.com";
echo "going to insert member\n";
$service->members->insert( $groupEmail, $member);
echo "DONE\n";
但是当这个脚本 运行s 它失败并输出这个
Built client
going to insert member
PHP Fatal error: Uncaught Google_Service_Exception: {
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Domain not found."
}
],
"code": 404,
"message": "Domain not found."
}
}
in /some/path/vendor/google/apiclient/src/Google/Http/REST.php:118
Stack trace:
#0 /some/path/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#1 /some/path/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#2 /some/path/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run()
#3 /some/path/vendor/google/apiclient/src/Google/Client.php(808): Google_Http_REST::execute(Object(GuzzleHttp\Client), Obje in /documents/zwp/helloasso2googlegroups/vendor/google/apiclient/src/Google/Http/REST.php on line 118
而且我不明白这个错误是什么意思,我找到的所有文档都让我觉得它与我应该 link 到 G Suite 帐户的域概念有关,但我我不太确定。
长话短说:如果您能给我指点以修复此错误,或者确认我无法在没有 G-Suite 帐户的情况下进行修复,我将非常高兴。
目录 API 仅支持 G Suite、教育版和政府版 Google 帐户。
无论如何,错误 404 与您的帐户状态无关,而是与您的凭据中缺少或错误的域有关。如果是这种情况,您会收到 403 错误 "Not Authorized to access this resource/api"
有关目录的更多信息 API 先决条件:https://developers.google.com/admin-sdk/directory/v1/guides/prerequisites
简而言之:
即使我没有 G-Suite 帐户,是否可以使用服务器端脚本将成员插入 Google 组?如果是,Domain not found
指的是什么?
更多详情
我正试图帮助一家小型非政府组织将他们管理新用户注册的部分工作自动化。特别是我正在设置一个脚本,它将在 google 组中插入新成员。
按照文档 I:
- 创建了一个服务帐户(从 https://console.developers.google.com/iam-admin/serviceaccounts )
- 启用了所需的 apis
- 运行 以下脚本使用 php 客户端 api
密码是:
<?php
require __DIR__ . '/vendor/autoload.php';
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json');
$client = new Google_Client();
$client->useApplicationDefaultCredentials();
$client->setApplicationName("GoogleGroup MA AutoUpdate");
$client->setScopes(array(
Google_Service_Directory::ADMIN_DIRECTORY_USER_READONLY,
Google_Service_Directory::ADMIN_DIRECTORY_GROUP
));
$user_to_impersonate = 'adminzwp@local-volt-214313.iam.gserviceaccount.com';
$client->setSubject($user_to_impersonate);
echo "Built client\n";
$service = new Google_Service_Directory($client);
$member = new Google_Service_Directory_Member();
$member->setEmail("some_test@hotmail.fr");
$member->setRole("MEMBER");
$groupEmail="myGroup@googlegroups.com";
echo "going to insert member\n";
$service->members->insert( $groupEmail, $member);
echo "DONE\n";
但是当这个脚本 运行s 它失败并输出这个
Built client
going to insert member
PHP Fatal error: Uncaught Google_Service_Exception: {
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Domain not found."
}
],
"code": 404,
"message": "Domain not found."
}
}
in /some/path/vendor/google/apiclient/src/Google/Http/REST.php:118
Stack trace:
#0 /some/path/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#1 /some/path/vendor/google/apiclient/src/Google/Task/Runner.php(176): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#2 /some/path/vendor/google/apiclient/src/Google/Http/REST.php(58): Google_Task_Runner->run()
#3 /some/path/vendor/google/apiclient/src/Google/Client.php(808): Google_Http_REST::execute(Object(GuzzleHttp\Client), Obje in /documents/zwp/helloasso2googlegroups/vendor/google/apiclient/src/Google/Http/REST.php on line 118
而且我不明白这个错误是什么意思,我找到的所有文档都让我觉得它与我应该 link 到 G Suite 帐户的域概念有关,但我我不太确定。
长话短说:如果您能给我指点以修复此错误,或者确认我无法在没有 G-Suite 帐户的情况下进行修复,我将非常高兴。
目录 API 仅支持 G Suite、教育版和政府版 Google 帐户。
无论如何,错误 404 与您的帐户状态无关,而是与您的凭据中缺少或错误的域有关。如果是这种情况,您会收到 403 错误 "Not Authorized to access this resource/api"
有关目录的更多信息 API 先决条件:https://developers.google.com/admin-sdk/directory/v1/guides/prerequisites