Google Calendar Event Not Showing in Calendar

前端 未结 2 1046
长情又很酷
长情又很酷 2020-12-04 00:35

We have created a Service Account in Google and Using Calendar API for adding events, it worked fine before ,after google stopped the account and reactivated it , it didn\'t

2条回答
  •  误落风尘
    2020-12-04 01:03

    In the past few weeks, my team have the same issues, and this is what my team's workaround.

    Our scenario

    1. We create a service account called google-calendar@mycompany.iam.gserviceaccount.com
    2. We using service account's credential from 1) for Google Calendar API
    3. Create an event into a service account's calendar like the code below
    calendar.events.insert({
      calendarId: 'primary', // it will create an event into service account's calendar
      resource: data,
      sendNotifications: true
    })
    

    What we have done for a workaround.

    1. Create a new company's user (let's say system@mycompany.com)
    2. Share system@mycompany.com's calendar with a service account by
      • going to "Calendar > Settings > Share with specific people" then
      • adding google-calendar@mycompany.iam.gserviceaccount.com with "Make changes to events"
    3. Update the code from creating an event to service account's calendar to just-created-user's calendar like a below
    calendar.events.insert({
      calendarId: 'system@mycompany.com', // << we changed from 'primary' to just-created-user
      resource: data,
      sendNotifications: true
    })
    

    After changing it, the created-event will be shown in Google Calendar as what it should.

    Hope this helps

提交回复
热议问题