0

I have a webhook that is receiving messages published from a topic via a subscription.

I also gave "Pub/Sub Publisher" role to gmail-api-push@system.gserviceaccount.com

I expected this to be sufficient to setup notifications for new mails.

Is there something I missed?

profimedica
  • 2,716
  • 31
  • 41

1 Answers1

0

Indeed, I had a functional Subscriber (my webhook). So, once the messages where available, I got notified. The issue was that I did not requested a watch.

https://developers.google.com/gmail/api/reference/rest/v1/users/watch

At this moment I had 2 more issues:

  1. Requesting a watch as per example above requires oAuth authentification.

  2. Push notifications only contains the historyId of the email. Not the Email ID required to fetch the content.

The email content can be fetched via https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get

I foud a solution in assigning domain-wide permissions to my service. Now I can read my own emails without using a oAuth popup to authentificate my user.

Client is unauthorized to retrieve access tokens using this method Gmail API C#

profimedica
  • 2,716
  • 31
  • 41