使用 spatie / laravel-google-calendar 模拟用户
Impersonate User using spatie / laravel-google-calendar
所以我想向在 google 日历上创建的活动的与会者发送邀请电子邮件。但当我这样做时
use Spatie\GoogleCalendar\Event as GoogleCalendarEvent;
$calendarEvent = new GoogleCalendarEvent;
$calendarEvent->name = $event->title;
$calendarEvent->startDateTime = $event->start_date;
$calendarEvent->endDateTime = $event->end_date;
$calendarEvent->addAttendee(['email' => 'isley269@gmail.com']);
$calendarEvent->save();
我收到错误
{ "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."
}
}
所以我已经为服务凭证授予了域范围的权限。但我仍然收到错误消息,因为我试图邀请使用服务帐户的用户。我如何使用 Spatie\GoogleCalendar 在 laravel 7 中使用此服务帐户模拟用户?
我尝试浏览 google 的 api 和 Spatie 的文档。但我找不到
此问题已在 Google 的 Public Issue Tracker
上报告
目前,服务帐户不允许在没有模拟的情况下邀请与会者。
为了实现模拟,您需要添加行
$client->setSubject('SPECIFY HERE THE USER TO IMPERSONATE');
使用服务帐户创建 new Google_Client()
时。
有关详细信息,请参阅 here。
所以我想向在 google 日历上创建的活动的与会者发送邀请电子邮件。但当我这样做时
use Spatie\GoogleCalendar\Event as GoogleCalendarEvent;
$calendarEvent = new GoogleCalendarEvent;
$calendarEvent->name = $event->title;
$calendarEvent->startDateTime = $event->start_date;
$calendarEvent->endDateTime = $event->end_date;
$calendarEvent->addAttendee(['email' => 'isley269@gmail.com']);
$calendarEvent->save();
我收到错误
{ "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."
}
}
所以我已经为服务凭证授予了域范围的权限。但我仍然收到错误消息,因为我试图邀请使用服务帐户的用户。我如何使用 Spatie\GoogleCalendar 在 laravel 7 中使用此服务帐户模拟用户?
我尝试浏览 google 的 api 和 Spatie 的文档。但我找不到
此问题已在 Google 的 Public Issue Tracker
上报告目前,服务帐户不允许在没有模拟的情况下邀请与会者。
为了实现模拟,您需要添加行
$client->setSubject('SPECIFY HERE THE USER TO IMPERSONATE');
使用服务帐户创建 new Google_Client()
时。
有关详细信息,请参阅 here。