'How to create google calendar Event having google meet link and invite other person with the help of google apis?
I'm using normal Gmail account and I have completed all the configuration related to Service account and Enable APIS on cloud.
In order to authorised request I'm using jwt method.
Simple google calendar event gets inserted but when I try to modify event data for google meeting link and attendees. It throws an error.
My system flow is like , On backend (Nodejs) crone job is running and create Event for calendar.
const CREDENTIALS = require('../../../calendar-meet-auth.json')
// Calendar scope for accessing
const CALENDAR_SCOPE = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events']
const calendar = google.calendar({ version: "v3" });
const calendarId = CREDENTIALS.calendarId;
// In order to authorized, each request from app
const auth = new google.auth.JWT(
CREDENTIALS.client_email,
null,
CREDENTIALS.private_key,
CALENDAR_SCOPE
);
// Event for Google Calendar
let event = {
'summary': `This is Test meeting scheduling with google meeting link`,
'description': `Please confirm.`,
attendees: [
{ email: '[email protected]' }
],
conferenceData: {
createRequest: {
requestId: getRandomString(),
conferenceSolutionKey: { type: "hangoutsMeet" },
},
},
'start': {
'dateTime': dateTime['start'],
'timeZone': 'Asia/Kolkata'
},
'end': {
'dateTime': dateTime['end'],
'timeZone': 'Asia/Kolkata'
},
// 'reminders': {
// 'useDefault': true,
// 'overrides': [
// { 'method': 'email', 'minutes': 24 * 60 },
// { 'method': 'popup', 'minutes': 10 },
// ],
// }
};
When it tries to add event , It throws error like .
Error: Service accounts cannot invite attendees without Domain-Wide Delegation of Authority..
Are there any alternatives ways to create Event with Google meet except Gsuit or Google workplace ?
Solution 1:[1]
- There does not seem to be an issue with the event payload itself.
- However, service accounts are not meant to interact with products as other types of users do. Some usage restrictions within Google APIs while authenticated as the service account (without impersonation) are indeed expected.
- In the Calendar API case, the caller of the
insertmethod will be the creator/organizer of that event. Therefore the creator/organizer of the event will be the authenticated account. - According to the error returned, it seems that the caller is indeed a service account (without impersonation)
- Since using Workspace isn’t an option, you won’t be able to impersonate another managed user with Domain wide delegation.
- Depending on your use case, an alternative would be to authenticate as an end user and create the event inviting the other gmail account as your sample code does.
- If you decide to do that, refer to this page to create/generate new credentials in your GCP project.
- Check out the Calendar quickstart for additional info as well
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Gustavo |
