0

我正在创建一个应用程序,我想添加在网站上注册的新成员,将它们添加到 Google 组,从那里我可以向他们发送自动电子邮件。但问题是我已经使用 Google Workspace 帐户创建了 oauth2.0 凭据(在客户端 ID、客户端密码的帮助下)我无法连接这些组。我收到错误:

PHP Fatal error:  Uncaught exception 'Google\Service\Exception' with message '{
  "error": "unauthorized_client",
  "error_description": "Unauthorized"
}' in /Project/googleWorkSpace/vendor/google/apiclient/src/Http/REST.php:128
Stack trace:
#0 /Project/googleWorkSpace/vendor/google/apiclient/src/Http/REST.php(103): Google\Http\REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google\\Service\\...')
#1 [internal function]: Google\Http\REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google\\Service\\...')
#2 /Project/googleWorkSpace/vendor/google/apiclient/src/Task/Runner.php(182): call_user_func_array(Array, Array)
#3 /Project/googleWorkSpace/vendor/google/apiclient/src/Http/REST.php(66): Google\Task\Runner->run()
#4 /Project/googleWorkSpace/vendor/google/apiclient/src/Client.php(899): Google\Http\REST::execute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google\\Service\ in /Project/googleWorkSpace/vendor/google/apiclient/src/Http/REST.php on line 128

我的 credentails.json 文件如下所示:

{
  "web": {
    "client_id": "211454******************************apps.googleusercontent.com",
    "project_id": "aapa-groups",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_secret": "rC***************4N",
    "redirect_uris": ["127.0.0.1"]
  }
}

我遵循与https://developers.google.com/admin-sdk/directory/v1/quickstart/php相同的代码。谁能帮助我如何授予获取 google 群组详细信息的权限,以便我可以添加他们文档中给出的成员。

4

0 回答 0