Coder Social home page Coder Social logo

googlecloudplatform / cloud-functions-gmail-nodejs Goto Github PK

View Code? Open in Web Editor NEW
52.0 9.0 23.0 1.05 MB

A demo app that processes Gmail messages with Cloud Functions

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

License: Apache License 2.0

JavaScript 100.00%

cloud-functions-gmail-nodejs's Introduction

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 redirect URIs: 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.

cloud-functions-gmail-nodejs's People

Contributors

justinbeckwith avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cloud-functions-gmail-nodejs's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Add very basic tests

This code is out there in the wild on a blog post. At a very minimum, we need to keep update dependencies so it works for new folks. I enabled renovate on the repo, but to have any confidence in the updates, we need some basic tests to make sure we don't break it :)

Auth Issue

I am trying this example, however the code fails with

TypeError: Cannot read property 'code' of undefined at OAuth2Client.getTokenAsync (/srv/node_modules/googleapis-common/node_modules/google-auth-library/build/src/auth/oauth2client.js:112:27) at OAuth2Client.getToken (/srv/node_modules/googleapis-common/node_modules/google-auth-library/build/src/auth/oauth2client.js:103:18) at Promise (/srv/index.js:56:18) at new Promise () at exports.oauth2callback (/srv/index.js:55:10) at /worker/worker.js:783:7 at /worker/worker.js:766:11 at _combinedTickCallback (internal/process/next_tick.js:132:7) at process._tickDomainCallback (internal/process/next_tick.js:219:9)

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • @google-cloud/datastore ^5.0.0
  • @google-cloud/debug-agent ^4.0.0
  • @google-cloud/vision ^1.0.0
  • cheerio ^1.0.0-rc.2
  • googleapis ^63.0.0
  • nconf ^0.11.0
  • pify ^4.0.0
  • mocha ^8.0.0
  • semistandard ^14.0.1
  • node >=8.13.0

  • Check this box to trigger a request for Renovate to run again on this repository

Deployment failure: Failed to retrieve function source code

Hi, thanks for your blog.

However, I failed to deploy your code after adding it to my own google cloud source repository. I see all your code in my source repository including index.js and package.json

My function definition refers to my google repository and \index.js but since it contains many functions as well as dependencies, do I need to deploy each function separately and how are dependencies package.json are going to be resolved during deployment?

Hope to hear from you soon.
Len
cloudFunction

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.