Einschränkung – Die Teilnehmer müssen nicht unbedingt eine Domänen-/Organisations-E-Mail-Adresse ([email protected]) haben, sondern können eine beliebige allgemeine Gmail-Adresse ([email protected]) sein.
Unten finden Sie den Code für Cloud Run
Code: Select all
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": [email protected]},
{"email": [email protected]},
],
}
print("Event Body:", event_body)
Code: Select all
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.'}]">
Würde ich nach der domänenweiten Delegation von Autorität immer noch ein Dienstkonto verwenden können?
Mobile version