Ограничение: участники не обязательно должны быть адресами электронной почты домена или организации (user@company.com), но могут быть любыми обычными пользователями Gmail (user@gmail.com).
Ниже приведен код Cloud Run
Код: Выделить всё
SCOPES = ["https://www.googleapis.com/auth/calendar"]
# 1) Get credentials for the service account this service runs as
credentials, project_id = google.auth.default(scopes=SCOPES)
# Refresh to ensure we have a token and metadata
credentials.refresh(Request())
# Get email associated with account
sa_email = getattr(credentials, "service_account_email", None)
print(f"Authenticated as service account: {sa_email}, project: {project_id}")
# 2) Build the Calendar API client
service = build("calendar", "v3", credentials=credentials)
# 3) Prepare the event
event_body = {
"summary": summary,
"description": description,
"start": {"dateTime": start},
"end": {"dateTime": end},
"attendees": [
{"email": test@gmail.com},
{"email": test2@gmail.com},
],
}
print("Event Body:", event_body)
Код: Выделить всё
ERROR: "Service accounts cannot invite attendees without Domain-Wide Delegation of Authority.". Details: "[{'domain': 'calendar', 'reason': 'forbiddenForServiceAccounts', 'message': 'Service accounts cannot invite attendees without Domain-Wide Delegation of Authority.'}]">
Смогу ли я по-прежнему использовать сервисный аккаунт после делегирования полномочий на уровне домена?>
Подробнее здесь: https://stackoverflow.com/questions/798 ... -attendees
Мобильная версия