googleapis / googleapis/google-api-nodejs-client

How can I find out which event was added, changed or deleted from Google Calendar in my webhook?

Aperta
#3,202 1 commento 4 reazioni 0 assegnatari Vedi su GitHub
priority: p3 type: question
Lingua principale
TypeScript
Stelle
12.2k
Fork
2k
Merge medio
1g 9h
PR unite (30g)
24

Descrizione

I added a watcher to events
```
calendar.events.watch({
calendarId: 'primary',
requestBody: {
id: 'my-unique-id',
type: 'web_hook',
address: 'https://my-server.com/api/events/calendar/webhook'
}
})
```
This returns me a data object as in the documentation.

```
{
"kind": "api#channel",
"id": string,
"resourceId": string,
"resourceUri": string,
"token": string,
"expiration": long
}
```
So, it works I think.

Then, I created a route for the webhook.
```
router.post('/calendar/webhook', async ctx => {
try {
console.log(ctx.request);
ctx.ok();
} catch (err) {
ctx.bad(400);
}
});
```

When I add a new event to the Google Calendar, I can see next in the console
This is the `ctx.request`
```
{
method: 'POST',
url: '/api/events/calendar/webhook',
header: {
host: 'my-server.com',
'user-agent': 'APIs-Google; (+https://developers.google.com/webmasters/APIs-Google.html)',
'content-length': '0',
accept: '*/*',
'accept-encoding': 'gzip, deflate, br',
'x-forwarded-for': '',
'x-forwarded-proto': 'https',
'x-goog-channel-expiration': 'Fri, 31 Mar 2023 14:56:37 GMT',
'x-goog-channel-id': 'my-unique-id',
'x-goog-message-number': '9712313484225',
'x-goog-resource-id': 'resource-id',
'x-goog-resource-state': 'exists',
'x-goog-resource-uri': 'https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json'
}
}
```

How do I find out what exactly was changed in Google Calendar? whether an event was added or deleted or changed, what exactly the event was, such as its id?

I would be grateful for any help.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

No repository file or test is named. Start with the Google Calendar events.watch documentation and the shown webhook route, then establish the documented way to identify affected events and define done as a clear explanation covering additions, changes, and deletions.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, nodejs
Ambito
api, backend
Tipo di issue
Documentazione
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.