1

Problem:

  • When using the service user auth and inserting / updating a calendar event, the reminders are not overridden
  • The event is inserted / updated correct APART from the reminders are always at the default (email > 10m, popup > 30m).

Context:

  • Node.js using standard libraries below
  • Valid service account with downloaded credentials.json
  • Service account (service-user-account@myapp.iam.gserviceaccount.com) has write access to myuser@gmail.com calendar

Code:

const {google} = require('googleapis')
const {auth} = require('google-auth-library')
const credentials = require('./credentials.json')

const addEvent = async (auth) => {
  const calendar = google.calendar({version: 'v3', auth})
  const insertRes = await calendar.events.insert({
    calendarId: 'myuser@gmail.com',
    resource: {
      summary: 'Test API',
      start: {
        dateTime: '2020-06-02T12:55:00.000',
        timeZone: 'Europe/London'
      },
      end: {
        dateTime: '2020-06-02T12:56:00.000',
        timeZone: 'Europe/London'
      },
      reminders: {
        useDefault: false,
        overrides: [
          {method: 'popup', 'minutes': 5}
        ]
      }
    }
  })
  console.log('insertRes', insertRes.data)
}

const getAuth = async () => {
  let client = auth.fromJSON(credentials)
  client.scopes = ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.events']
  return client
}
const init = async () => {
  const auth = await getAuth()
  await addEvent(auth)
}
init()

Response: from console.log(insertRes)

{ kind: 'calendar#event',
  etag: '"3182200547452000"',
  id: '6063phndufgppo8rfev1XXXXXX',
  status: 'confirmed',
  htmlLink:
   'https://www.google.com/calendar/event?eid=NjA2M3BobmR1ZmdwcG84cmZldjFjdWh2YzQgZGFuZ2FyZmllbGR1a0Bnb29nbGVtYWlsXXXXXX',
  created: '2020-06-02T12:17:53.000Z',
  updated: '2020-06-02T12:17:53.768Z',
  summary: 'Test API',
  creator:
   { email: 'service-user-account@myapp.iam.gserviceaccount.com' },
  organizer: { email: 'myuser@googlemail.com', self: true },
  start:
   { dateTime: '2020-06-02T12:55:00+01:00',
     timeZone: 'Europe/London' },
  end:
   { dateTime: '2020-06-02T12:56:00+01:00',
     timeZone: 'Europe/London' },
  iCalUID: '6063phndufgppo8rfev1XXXXXX@google.com',
  sequence: 0,
  reminders: { useDefault: false, overrides: [{"method":"popup","minutes":5}] }
}

Hopefully someone can shed a light on the issue for me.

Thanks

dangarfield
  • 2,210
  • 1
  • 13
  • 18
  • By "service user auth" I assume you mean service account user, Does this work with Oauth2? Google has added a lot of restrictions as far as service accounts sending notifications when adding events. You might want to brouse around the issue forum. – Linda Lawton - DaImTo Jun 02 '20 at 12:57
  • Yes, apologies, service account user based authentication. This is a tiny pet project with no public access so OAuth2 won't be appropriate here. Nonetheless, I have also been reading up on this and it could be a 'feature' that is related to ensuring the organiser's notifications are controlled by the organiser and not the proxied server account user. I don't think that the documentation is pretty on this issue and as someone has pointed out there appears to be a bug. If this is not a bug, I'm am still in the dark with how to proceed with service account base auth. Thanks though – dangarfield Jun 02 '20 at 15:08

2 Answers2

1

It seems to be a bug, already reported on Google's Public Issue Tracker

Give it a "star" to show that more people are affected and to receive updates on the issue.

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
1

The service account user is a user more or less just like you. One can only modify reminders for the current user, not for other users.

The reminder is set, but for the "wrong" user. Try to get the event through api with the service account user, you will see the reminder there. Add a reminder with your own user through UI and do the api request again, you will not be able to see the new reminder.

If you want to set reminders on events for yourself, be sure to use your own account to modify the event, for example with OAuth 2.0.

dominikkv
  • 216
  • 3
  • 13
  • Thanks for the response and understand why it is important for the target user to have 100% control over the editing of the notifications. The fact that the API disregards the initial insert content params and uses the default reminder (all of which is undocumented) doesn't sound right at all. I would expect that there should be no reminder in that case. I believe this should remain as a bug for inserts. It completely invalidates any reason for me to use a service account and forces OAuth, which is hugely overkill for my use case at least – dangarfield Jul 10 '20 at 17:46