简体   繁体   English

无法与与会者一起创建谷歌日历活动

[英]Unable to create google calendar event with attendees

I am using this PHP Google Client Library for creating google calendar events.我正在使用这个PHP Google Client Library来创建谷歌日历事件。 My requirement is to create a calendar event on the account I created credentials with and also need to create the same event for attendees.我的要求是在我创建凭据的帐户上创建一个日历事件,并且还需要为与会者创建相同的事件。 This is my code这是我的代码

$credentials = credentials.json';
require '\vendor\autoload.php';

$client = new Google_Client();
$client->setScopes(Google_Service_Calendar::CALENDAR);
$client->setAuthConfig($credentials);

$service = new Google_Service_Calendar($client);

$event = new Google_Service_Calendar_Event(array(
    'summary' => 'Testing for g calender',
    'location' => 'ABC',
    'description' => 'A chance to hear more about Google\'s developer products.',
    'start' => array(
      'dateTime' => '2022-01-05T09:00:00-07:00',
      'timeZone' => 'America/Los_Angeles',
    ),
    'end' => array(
      'dateTime' => '2022-12-28T17:00:00-07:00',
      'timeZone' => 'America/Los_Angeles',
    ),
    'recurrence' => array(
      'RRULE:FREQ=DAILY;COUNT=2'
    ),
    'attendees' => array(
      array('email' => 'attendee1@gmail.com'),
      array('email' => 'attendee2@gmail.com')
    ),
    'reminders' => array(
      'useDefault' => FALSE,
      'overrides' => array(
        array('method' => 'email', 'minutes' => 24 * 60),
        array('method' => 'popup', 'minutes' => 10),
      ),
    ),
  ));
  
  $calendarId = 'primary';
  $event = $service->events->insert($calendarId, $event);
  printf('Event created: %s\n', $event->htmlLink);

The problem is this code only works when i run this without attendees with attendees it is not working and returns me this error问题是此代码仅在我在没有与会者的情况下与与会者一起运行时才有效,它不起作用并返回此错误

Fatal error: Uncaught Google_Service_Exception: { "error": { "errors": [ { "domain": "calendar", "reason": "forbiddenForServiceAccounts", "message": "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority." } ], "code": 403, "message": "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority." } }

I look for this issue on the internet and find out that i need a G-Suit account in order to enable this Domain Wide Delegation so get the G-Suit account and followed these steps which are mentioned in google documentation.我在互联网上查找此问题并发现我需要一个 G-Suit 帐户才能启用此域范围委派,因此获取 G-Suit 帐户并按照谷歌文档中提到的这些步骤进行操作。

在此处输入图像描述

but still, this does not help me out and I am still unable to activate this Domain Wide Delegation feature on my account.但是,这仍然对我没有帮助,我仍然无法在我的帐户上激活此域范围委派功能。 I am still seeing this feature as it is.. ANY HELP !!我仍然按原样看到此功能..任何帮助!

Domain wide deligation can only be configured by the google workspace admin.域范围的委托只能由谷歌工作区管理员配置。 The service account needs to have been created on google cloud console by a user on the domain.该服务帐户需要由域中的用户在谷歌云控制台上创建。

To be 100% clear standard gmail users can't be used for deligation to a service account. 100% 明确标准 gmail 用户不能用于委托服务帐户。 Everything must remain within your workspace domain.一切都必须保留在您的工作区域内。

Your code also needs to denote the user on your domain the service account should be impersonating您的代码还需要指出服务帐户应该模拟的域中的用户

$client->setSubject('redacted@daimto.com);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM