google.calendar.events.insert fails when adding conferenceData
See original GitHub issueEnvironment details
- OS: firebase-tools@10.9.2
- Node.js version: v16.15.1
- npm version: 8.11.0
googleapis
version: googleapis@107.0.0
Steps to reproduce
Steps to reproduce
Create google event using google.calendar.events.insert
Returned error: Invalid conference type value
API is authenticated as google service account and domain-wide delegation is done from google workspace admin. Using Google Workspace Business Starter account.
The service account works with no issue, and the meeting is created whenconferenceDataVersion: 1
is not set
here is the snippet:
const SCOPES = ["https://www.googleapis.com/auth/calendar"];
const jwtClient = new google.auth.JWT(
GOOGLE_CLIENT_EMAIL,
null,
GOOGLE_PRIVATE_KEY,
SCOPES,
);
const calendar = google.calendar({
version: "v3",
project: GOOGLE_PROJECT_NUMBER,
auth: jwtClient,
});
const auth = new google.auth.GoogleAuth({
keyFile: "./keys.json",
scopes: SCOPES,
});
// Add event to calendar and get the link
const calendarEvent = {
summary: "Test",
description: "Test.",
start: {
dateTime: data.booking.startDate,
timeZone: "America/Los_Angeles", // TODO figure out timezones
},
end: {
dateTime: data.booking.endDate,
timeZone: "America/Los_Angeles", // TODO figure out timezones
},
conferenceData: {
createRequest: {
requestId: "sample123",
conferenceSolutionKey: {type: "hangoutsMeet"},
},
},
attendees: [],
reminders: {
useDefault: false,
overrides: [
{method: "email", minutes: 24 * 60},
{method: "popup", minutes: 10},
],
},
};
addCalendarEvent(calendarEvent);
const addCalendarEvent = async (calendarEvent) => {
try {
auth.getClient().then(async (auth) => {
console.log("addCalendarEvent: " +GOOGLE_CALENDAR_ID);
try {
calendar.events.insert(
{
auth: auth,
calendarId: GOOGLE_CALENDAR_ID,
resource: calendarEvent,
conferenceDataVersion: 1, // Doesnt work
},
function(error, response) {
console.log(JSON.stringify(response));
if (error) {
console.log("Something went wrong:" + JSON.stringify(error)); // If there is an error, log it to the console
return;
}
console.log("Event created successfully.");
console.log("Event details: ", JSON.stringify(response.data)); // Log the event details
},
);
} catch (err) {
console.log("Error in insert: ", JSON.stringify(err));
}
});
} catch (err) {
console.log("Error in auth: ", JSON.stringify(err));
}
};
Output when using hangoutsMeet
,eventHangout
or eventNamedHangout
:
Something went wrong:{“response”:{“config”:{“project”:“1082487788583”,“url”:“https://www.googleapis.com/calendar/v3/calendars/robert%40hustleforge.com/events?conferenceDataVersion=1",“method”:“POST”,“userAgentDirectives”:[{“product”:“google-api-nodejs-client”,“version”:“6.0.1”,“comment”:“gzip”}],“data”:{“summary”:“test”:“test.”,“start”:{“dateTime”:“2022-09-02T18:00:00.000Z”,“timeZone”:“America/Los_Angeles”},“end”:{“dateTime”:“2022-09-02T19:00:00.000Z”,“timeZone”:“America/Los_Angeles”},“conferenceData”:{“createRequest”:{“requestId”:“sample123”,“conferenceSolutionKey”:{“type”:“eventHangout”}}},“attendees”:[],“reminders”:{“useDefault”:false,“overrides”:[{“method”:“email”,“minutes”:1440},{“method”:“popup”,“minutes”:10}]}},“headers”:{“x-goog-api-client”:"gdcl/6.0.1 gl-node/14.20.0 auth/8.3.0”,“Accept-Encoding”:“gzip”,“User-Agent”:“google-api-nodejs-client/6.0.1 (gzip)”,“Authorization”:“XXX”,“Content-Type”:“application/json”,“Accept”:“application/json”},“params”:{“conferenceDataVersion”:1},“retry”:true,“body”:“{"summary":"test","description":"test.","start":{"dateTime":"2022-09-02T18:00:00.000Z","timeZone":"America/Los_Angeles"},"end":{"dateTime":"2022-09-02T19:00:00.000Z","timeZone":"America/Los_Angeles"},"conferenceData":{"createRequest":{"requestId":"sample123","conferenceSolutionKey":{"type":"eventHangout"}}},"attendees":[],"reminders":{"useDefault":false,"overrides":[{"method":"email","minutes":1440},{"method":"popup","minutes":10}]}}”,“responseType”:“json”,“retryConfig”:{“currentRetryAttempt”:0,“retry”:3,“httpMethodsToRetry”:[“GET”,“HEAD”,“PUT”,“OPTIONS”,“DELETE”],“noResponseRetries”:2,“statusCodesToRetry”:[[100,199],[429,429],[500,599]]}},“data”:{“error”:{“errors”:[{“domain”:“global”,“reason”:“invalid”,“message”:“Invalid conference type value.”}],“code”:400,“message”:“Invalid conference type value.”}},“headers”:{“alt-svc”:“h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"”,“cache-control”:“no-cache, no-store, max-age=0, must-revalidate”,“connection”:“close”,“content-encoding”:“gzip”,“content-type”:“application/json; charset=UTF-8”,“date”:“Wed, 24 Aug 2022 04:57:17 GMT”,“expires”:“Mon, 01 Jan 1990 00:00:00 GMT”,“pragma”:“no-cache”,“server”:“ESF”,“transfer-encoding”:“chunked”,“vary”:“Origin, X-Origin, Referer”,“x-content-type-options”:“nosniff”,“x-frame-options”:“SAMEORIGIN”,“x-xss-protection”:“0”},“status”:400,“statusText”:“Bad Request”,“request”:{“responseURL”:“https://www.googleapis.com/calendar/v3/calendars/robert%40hustleforge.com/events?conferenceDataVersion=1"}},“config”:{“project”:“1082487788583”,“url”:“https://www.googleapis.com/calendar/v3/calendars/robert%40hustleforge.com/events?conferenceDataVersion=1”,“method”:“POST”,“userAgentDirectives”:[{“product”:“google-api-nodejs-client”,“version”:“6.0.1”,“comment”:“gzip”}],“data”:{“summary”:“test”,“description”:“test.”,“start”:{“dateTime”:“2022-09-02T18:00:00.000Z”,“timeZone”:“America/Los_Angeles”},“end”:{“dateTime”:“2022-09-02T19:00:00.000Z”,“timeZone”:“America/Los_Angeles”},“conferenceData”:{“createRequest”:{“requestId”:“sample123”,“conferenceSolutionKey”:{“type”:“eventHangout”}}},“attendees”:[],“reminders”:{“useDefault”:false,“overrides”:[{“method”:“email”,“minutes”:1440},{“method”:“popup”,“minutes”:10}]}},“headers”:{“x-goog-api-client”:"gdcl/6.0.1 gl-node/14.20.0 auth/8.3.0”,“Accept-Encoding”:“gzip”,“User-Agent”:“google-api-nodejs-client/6.0.1 (gzip)”,“Authorization”:“XXX”,“Content-Type”:“application/json”,“Accept”:“application/json”},“params”:{“conferenceDataVersion”:1},“retry”:true,“body”:“{"summary":"test","description":"test","start":{"dateTime":"2022-09-02T18:00:00.000Z","timeZone":"America/Los_Angeles"},"end":{"dateTime":"2022-09-02T19:00:00.000Z","timeZone":"America/Los_Angeles"},"conferenceData":{"createRequest":{"requestId":"sample123","conferenceSolutionKey":{"type":"eventHangout"}}},"attendees":[],"reminders":{"useDefault":false,"overrides":[{"method":"email","minutes":1440},{"method":"popup","minutes":10}]}}”,“responseType”:“json”,“retryConfig”:{“currentRetryAttempt”:0,“retry”:3,“httpMethodsToRetry”:[“GET”,“HEAD”,“PUT”,“OPTIONS”,“DELETE”],“noResponseRetries”:2,“statusCodesToRetry”:[[100,199],[429,429],[500,599]]}},“code”:400,“errors”:[{“domain”:“global”,“reason”:“invalid”,“message”:“Invalid conference type value.”}]}
Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top GitHub Comments
Hey! Thanks for the suggestions. Good to know you have it working, means it’s possible. I follow your steps to see if I’m missing something.
Hey @herbola thanks for the suggestion. This didn’t work for me though and the service account kept getting an error while trying to impersonate the admin. Even after supplying all available permissions and roles.
I just abandoned service accounts entirely and instead authenticated directly with an admin account.
I first created an OAuth application on Google Cloud, then used that to Authenticate admin users from which I’d get a
refresh_token
. This refresh token would be used internally in the app to generate new access tokens when needed.A refresh token would expire in about if not used for 6 months, at which point the admin user would have to generate a new one. This would not be a problem for my use-case as the feature which I need the Events API for is only called by admin users.
Getting credentials
I exposed the two methods of this service on the server accessible only by admin users. The admin user just has to call the first method and then follow throught with Google’s authentication. When this completes, the second method would be called to save the credentials (auth_token, refresh_token, etc) on the server.
Using the credentials
Where