hashkanna / cloud-functions-gmail-nodejs

A demo app that processes Gmail messages with Cloud Functions

Home Page:https://cloud.google.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gmail + GCF intelligence demo

This repository demonstrates how to write custom mail processing logic for Gmail using the Gmail API and Cloud Functions. See the blog post for more information.

Obtaining an OAuth 2.0 Client ID

In order for an OAuth 2.0 API to verify our program's identity, we must include an OAuth 2.0 client ID with some of our requests to the API. The following steps show how to enable the Gmail API and download the client ID to your local machine.

  1. Enable the Gmail API using the the Gmail API page in the GCP Console.

  2. Find the GCP region you want to deploy your function to. (In general, response time is quickest for the regions closest to you.) For the rest of this tutorial, replace [YOUR_GCF_REGION] with your selected region's name (for example, us-central1).

  3. Generate a new OAuth 2.0 client ID by visiting the GCP Console credentials page. Configure the fields as indicated below:

    • Application type: Web application
    • Name: an appropriate, memorable name for your client
    • Authorized JavaScript origins: https://[YOUR_GCF_REGION]-[YOUR_GCP_PROJECT_ID].cloudfunctions.net/oauth2callback
  4. Click Create, then close the resulting dialog box and click the Download icon next to your newly created client ID. The resulting file is your Client Secret file.

Configuring local files

  1. Rename your Client Secret file to client_secret.json, and move it to the directory that contains your index.js and package.json files.
  2. In config.json, update the values for GCF_REGION, GCLOUD_PROJECT, and TOPIC_ID.

About

A demo app that processes Gmail messages with Cloud Functions

https://cloud.google.com

License:Apache License 2.0


Languages

Language:JavaScript 100.0%