问题描述 投票:0回答:1

我有一个节点应用程序,使用netlify dev在lamda函数中本地运行。我收到500响应错误,不确定为什么我可以肯定我拥有所有正确的凭据。我不知道该如何调试。希望有人可以帮助我阅读有关尝试发送响应3s然后6s的信息,依此类推,但这仍然返回了完全相同的问题。这是我第一次使用api,因此无法完全确定该怎么做。


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

    const oAuth2Client = new oAuth2(


    // 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.
        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 =

        // 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.
            { 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...`)
google-calendar-api oauth2-playground


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