Git Product home page Git Product logo

apps-script-gmail-push-notifications's Introduction

Apps-Script-Gmail-Push-Notifications

A very rough example on how to get push notification from gmail in Google Apps Script

note: I added a initByServiceAccount folder. In there you can see an example on how to create the notiofication pub/sub and enroll users in your domain using a service account.

Some setup notes: For this to work you must first publish your script as a draft to the chrome webstore. Then in the dev console add your scripts published webapp URL without the trailing '/exec' to APIs & Auth -> Push

This uses the Oauth2 Library for authentication: MswhXl8fVhTFUH_Q3UOJbXvxhMjh3Sh48
https://github.com/googlesamples/apps-script-oauth2

Enable the APIs: Google Cloud Pub/Sub and Gmail Api
Generate web credentials. Add the client_id and client_secret to the script properties.

Change the TOPIC and SUBSCRIPTION strings for your own project id, topic and subscriptions names. The names can be whatever you choose and are simply frendly names to use for reference.
Change the ENDPOINTURL to the url of your published webapp. This should match what you put into the Dev Console but addidng the '/exec'

var TOPIC = "projects/{Your Dev Console ProjectId}/topics/{Topic Name}";
var SUBSCRIPTION = "projects/{Your Dev Console ProjectId}/subscriptions/{Subscription Name}";

  1. run as webapp pointing to CloudAuthWindow();
    1)makeTopic()
    2)subscribe()
    3)grantPublishRights()
    4)run as web app pointing to GmailAuthWindow()
    5)Logging will start at this point.
  2. enrollEmail() must be ran atleast one a week to remain active.

apps-script-gmail-push-notifications's People

Contributors

spencer-easton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.