我已经为此苦苦挣扎了几天。我只想编辑 Google 日历中的活动并向其中添加 google meet。 因此,首先我在日历中成功创建了该活动,付款后我想添加 google meet 链接,但没有运气。
我按照以下说明设置我的环境:https://www.geeksforgeeks.org/how-to-integrate-google-calendar-in-node-js/
这是我如何连接到谷歌日历的代码
const googleAuth = new google.auth.GoogleAuth({
keyFile: `${__dirname}/../config/app-232131jdais2.json`,
scopes: ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events'],
})
export async function getCalendar() {
const auth = await googleAuth.getClient()
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return google.calendar({
version: 'v3',
project: process.env.GOOGLE_PROJECT_ID,
auth,
})
}
export async function updateCalendarEvent(calendarId: string, eventId: string, eventUpdate: any) {
const calendar = await getCalendar()
// @ts-ignore
return calendar.events.patch({
calendarId,
eventId,
resource: eventUpdate,
sendNotifications: true,
conferenceDataVersion: 1,
})
}
从谷歌文档中我可以:
const updateEvent = {
description: `Meeting is paid here is your link....`,
conferenceData: {
createRequest: {
requestId: "7qxalsvy0e", /// --> this is random uuid
},
},
}
const updateEventResponse = await updateCalendarEvent(calendarId, eventId, updateEvent)
运行后,我从 Google API 得到 200 ok,但没有指向 google meet 的链接,而且在日历中我没有看到添加的会议。
我尝试过:
const updateEvent = {
description: `Meeting is paid here is your link....`,
conferenceData: {
createRequest: {
requestId: "7qxalsvy0e",
conferenceSolutionKey: { type: "hangoutsMeet" },
},
},
}
const updateEventResponse = await updateCalendarEvent(calendarId, eventId, updateEvent)
但是使用conferenceSolutionKey: { type: "hangoutsMeet" },我得到的信息是:
Error: Invalid conference type value. at Gaxios._request (.../googleapis-common/node_modules/gaxios/src/gaxios.ts:172:15) at processTicksAndRejections (internal/process/task_queues.js:93:5) at JWT.requestAsync (.../node_modules/googleapis-common/node_modules/google-auth-library/build/src/auth/oauth2client.js:383:18)
阅读 stackoverflow 得知我需要 Google Workspace,因此我付费购买了这样一个帐户,但结果还是一样。
我也这么做了:
在您的服务帐户中启用域范围委派
1 - 向您的服务帐户提供日历范围
前往 https://admin.google.com/ 并使用 G Suite 帐户登录。
转到安全性 -> API 控制 -> 域范围委派
添加新=>设置您的服务帐户的客户端ID(只有数字的) 设置以下范围:
请帮忙:)