google 日历请求出现 500 错误

Getting a 500 error for google calendar request

我有一个节点应用程序,我是 运行 在本地使用 netlify dev 的 lamda 函数。我收到 500 响应错误,不确定为什么我非常确定我拥有所有正确的凭据。我不知道如何调试它。希望有人可以帮助我阅读一些有关尝试发送响应 3 秒然后 6 秒等等的内容,但仍然返回完全相同的问题。这是我第一次使用 api,所以不太确定该怎么做。

请记住,我正在使用开发人员游乐场作为我的 oauth 重定向,并在那里生成了一个刷新令牌

const { google } = require("googleapis")
const { oAuth2 } = google.auth


    const oAuth2Client = new oAuth2(
      "fdsfs.apps.googleusercontent.com",
      "fdsaf"
    )

    oAuth2Client.setCredentials({
      refresh_token:
        "1//0fdsfas",
    })

    // Create a new calender instance.
    const calendar = google.calendar({ version: "v3", auth: oAuth2Client })

    // Create a new event start date instance for temp uses in our calendar.
    const eventStartTime = new Date()
    eventStartTime.setDate(eventStartTime.getDay() + 2)

    // Create a new event end date instance for temp uses in our calendar.
    const eventEndTime = new Date()
    eventEndTime.setDate(eventEndTime.getDay() + 4)
    eventEndTime.setMinutes(eventEndTime.getMinutes() + 45)

    // Create a dummy event for temp uses in our calendar
    const event = {
      summary: `Meeting with David`,
      location: `3595 California St, San Francisco, CA 94118`,
      description: `Meet with David to talk about the new client project and how to integrate the calendar for booking.`,
      colorId: 1,
      start: {
        dateTime: eventStartTime,
        timeZone: "America/Denver",
      },
      end: {
        dateTime: eventEndTime,
        timeZone: "America/Denver",
      },
    }

    // Check if we a busy and have an event on our calendar for the same time.
    calendar.freebusy.query(
      {
        resource: {
          timeMin: eventStartTime,
          timeMax: eventEndTime,
          timeZone: "America/Denver",
          items: [{ id: "primary" }],
        },
      },
      (err, res) => {
        // Check for errors in our query and log them if they exist.
        if (err) return console.error("Free Busy Query Error: ", err)

        // Create an array of all events on our calendar during that time.
        const eventArr = res.data.calendars.primary.busy

        // Check if event array is empty which means we are not busy
        if (eventArr.length === 0)
          // If we are not busy create a new calendar event.
          return calendar.events.insert(
            { calendarId: "primary", resource: event },
            err => {
              // Check for errors and log them if they exist.
              if (err)
                return console.error("Error Creating Calender Event:", err)
              // Else log that the event was created.
              return console.log("Calendar event successfully created.")
            }
          )

        // If event array is not empty log that we are busy.
        return console.log(`Sorry I'm busy...`)
      }
    )

这是一个简单的错误

const { OAuth2 } = google.auth with capital O !not oAuth2