Where to receive watch notifications for gmail in .NET?

Viewed 36

I'm trying to receive watch notification for Gmail mailboxes in my .NET C# program.

I have the following code:

WatchRequest body = new WatchRequest()
{
    LabelIds = labelIds,
    TopicName = PrivateKeys.GoogleGmailTopic
};

WatchResponse response = new UsersResource.WatchRequest(_gmailService, body, "me")
{
    Key = PrivateKeys.GoogleApiKey,
    OauthToken = AccessToken
}
    .Execute();

... and it seems to work, since I get a response.

But where do I receive these notifications inside my program? How can I configure the event entry point?

1 Answers

Assuming you did the preliminary work to set up a Cloud Pub/Sub client (described here: https://developers.google.com/gmail/api/guides/push#initial_cloud_pubsub_setup), you should have a Pub/Sub subscription - either PULL or PUSH.

In order to get the notifications, your application should initiate a subscriber, you can follow the instructions in https://cloud.google.com/pubsub/docs/pull for PULL or in https://cloud.google.com/pubsub/docs/push for PUSH. Configuring the event entry point should be done as part of the subscriber set up.

Related