我想访问与我的帐户及其评论关联的位置,因为我正在使用 google 我的业务 API 并且我可以访问它(它确实在 oAuthplayground 上工作)。
现在我想在不登录我的帐户的情况下访问 google my business api,因为我正在尝试使其与服务帐户一起使用。但到目前为止还没有运气,请建议如何进行。我已在服务帐户中启用了 G 套件,并且我还尝试为我的业务管理授予对服务帐户电子邮件 (ID) 的访问权限,但它仍处于已邀请状态,因为无法实际接受邀请。
当我尝试使用我的帐户作为主题发送请求时。
$client = new Google_Client();
$client->addScope('https://www.googleapis.com/auth/plus.business.manage');
$client->setAuthConfig(dirname(__FILE__) . '/Xyz Review API-service account.json');
$client->setSubject('xyz*****abc@gmail.com');
$business_service_class = new Google_Service_Mybusiness($client);
$result_accounts = $business_service_class->accounts->listAccounts();
echo json_encode($result_accounts);
exit;
响应:{"nextPageToken":null}
如果我在主题中使用 google 服务帐户 ID 作为电子邮件 ID,那么我会收到以下回复。
$client->setSubject('xyz-review-service@xyz-review-api.iam.gserviceaccount.com');
响应:错误 500 {“error”:“unauthorized_client”,“error_description”:“请求中的未授权客户端或范围。” }
如果我这样做完全错误,那么请建议如何进行。谢谢你。