Giter VIP home page Giter VIP logo

gcf-gmail-codelab's Introduction

Empower Your Gmail Inbox with Google Cloud Functions CodeLab

Note: This is not an officially supported Google product.

Write something.

gcf-gmail-codelab's People

Stargazers

 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

gcf-gmail-codelab's Issues

Error in auth process

I get an error when trying to authorize my application to my gmail account to activate push notifications.
When clicking the link in the "Trigger" tab in the auth_init function -- choosing the email account - clicking past the unverified app page - allowing permissions -> then i get this message after confirmation of settings:
"An error has occurred in the authorization process."

Console in Chrome says:
Cross-Origin Read Blocking (CORB) blocked cross-origin response https://appengine.google.com/_ah/loginform?state=~AJKiYcGSoGF9FIKAWtQzvyjvE_kEnQ_NbMCaCgc_BHxeTRx77TZZzzwPBWBLeh0tSJ76YwdLFYDTK4c-bdp2sq00DHo3cvS5eCe8yttlof_9F_DIrTRP0Ki9t98iM0tX1rQl6gJXEVbdIBjDFd21fs8WiUsEoJIngXwLEoaKkIm-Xy1Yxfq1pI4aGA-PL_R2rSWmAXapaNN6k3aIUmEmmjMBsJxMmg05VQDIN_D4TgIIuHlSwavLlCRtTREgOCoFCUpzja6_9AMz5sTrbicdzblRWJ4YeVdnpYbE8AbP9X76z48OWGkYgjQWFopnV7DpQl0r0MYC-XZjthMF-XgeaxzJnjIyhWlVQMrV60HvUnri6uFvEnNFJpgixlOkW0CDteWjdsmDeZ3w with MIME type text/html. See https://www.chromestatus.com/feature/5629709824032768 for more details.

Auth callback shows an error:

TypeError: Cannot read property 'split' of undefined
at handler (/srv/node_modules/@google-cloud/express-oauth2-handlers/routes.js:50)
at (/srv/node_modules/@google-cloud/express-oauth2-handlers/routes.js:114)
at (/worker/worker.js:783)
at (/worker/worker.js:766)
at _combinedTickCallback (internal/process/next_tick.js:132)
at process._tickDomainCallback (next_tick.js:219)

I also tried running Chrome with --disable-web-security to try to disable CORB -- the error disappears frmo the console about CORB but the message in is the same.

Any ideas?

Domain verification

Can't pass step 4. In the domain verification it asks me to verify ownership:
Verify ownership:
Before you register <project_url> you must first verify ownership. You can do this in the Google Search Console.

Unable to redeploy auth_init or auth_callback - even after making no changes at all

Another problem on this lab - probably related to the Node 8 change.

I can deploy the auth_init and auth_callback functions, despite getting a warning about Node 8 being deprecated.

Then, I was getting frustrated because I'd get a failure to deploy when trying to add the callback URL (as per the lab instructions, page 4). So I tried to redeploy with no changes at all. And that failed.

Lots of errors apparently related to secrets and needing GCP_PROJECT set. Since most back end I do is in GO, this is not stuff I know.

Domain Verification

I can't get past the domain verification. I add the domain and google asks me to verify it. It takes to a verification page and asks me to upload a small HTML file to the site which I did, but it won't verify.

An error has occurred in the authorization process - after clicking the auth_init trigger URL and completing permission flow

I was able to deploy the functions and add all the env_vars.yml and deploy a second time having completed the permissions grants. However, at step 5 "Setup Gmail push notifications" after clicking "Allow" I get the error: "An error has occurred in the authorization process".

GCP Logging is full of only one error, but this was present before I was able to get to the "Allow" step 5.

2021-11-04T18:08:05.121Zauth_callback Searching for secrets in: /workspace/node_modules/@google-cloud/client_secret.json
2021-11-04T18:08:05.122Zauth_callback Provided module can't be loaded.
2021-11-04T18:08:05.122Zauth_callback Is there a syntax error in your code?
2021-11-04T18:08:05.122Zauth_callback Detailed stack trace: Error: Missing required keys: GCP_PROJECT
2021-11-04T18:08:05.122Zauth_callback at exports.Provider.Provider.required (/workspace/node_modules/nconf/lib/nconf/provider.js:364:11)
2021-11-04T18:08:05.123Zauth_callback at Object.<anonymous> (/workspace/node_modules/@google-cloud/express-oauth2-handlers/config.js:53:7)
2021-11-04T18:08:05.123Zauth_callback at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-11-04T18:08:05.123Zauth_callback at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-11-04T18:08:05.123Zauth_callback at Module.load (internal/modules/cjs/loader.js:937:32)
2021-11-04T18:08:05.123Zauth_callback at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-11-04T18:08:05.123Zauth_callback at Module.require (internal/modules/cjs/loader.js:961:19)
2021-11-04T18:08:05.123Zauth_callback at require (internal/modules/cjs/helpers.js:92:18)
2021-11-04T18:08:05.123Zauth_callback at Object.<anonymous> (/workspace/node_modules/@google-cloud/express-oauth2-handlers/tokenStorage.js:17:16)
2021-11-04T18:08:05.123Zauth_callback at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-11-04T18:08:05.123Zauth_callback Could not load the function, shutting down.

Note the "Error: Missing required keys: GCP_PROJECT". I tried to set GCP_PROJECT in the env vars, but get an error that it is a protected env var. I renamed the value in index.js to _GCP_PROJECT and did the same for env vars, but the error persisted making me think it is in another lib.

A note to the authors, the URLs of auth_callback and the pubsub only differ by GCP project. Several steps could be saved by creating the values in the file at the beginning.

Delegation denied at GAxios

Thanks for this awesome codelab at first. It works fine with a single Gmail account. I tried to read the email from different email accounts for which i just used the URL which is available in auth_init.

Authorization was successful but when a new message comes in. I am getting an error like Delegation denied at GAxios for the primary email account.

But if i send an email from my primary account to the second one it reads the email and the task executed successfully.

May i know why the Delegation denied error is coming.

gmail.users.messages.list getting messages.id for a different gmail account I have

I came across a random issue, I am testing this out with multiple gmail accounts.

A few months ago I had one of my gmail account connected up, the token had obviously expired, so I reauthorized access, that all worked as expected.

In the logs, I saw that the gmail.users.messages.list returned a message.id for a different gmail account I am also testing with, and I was able to confirm this by using this https://developers.google.com/gmail/api/reference/rest/v1/users.messages/get against the other account.

This is my code, note that I modified it to be 'me', and looking in the logs, it eventually stops returning the wrong id but the problem is that the actual email that triggered the pub/sub is "skipped".

any ideas?

const getMostRecentMessageWithTag = async (email, historyId) => {
  // Look up the most recent message.
  console.log(`getMostRecentMessageWithTag email: ${email} `);
  const listMessagesRes = await gmail.users.messages.list({
    userId: 'me',   // use 'me' instead of email
    labelIds: ['INBOX'],
    maxResults: 1,
    includeSpamTrash: false
  });
....
    const message = await gmail.users.messages.get({
      userId: 'me',   // use 'me' instead of email
      id: messageId
    });

Update request

The codelab works very good, but since Datastore evolve into Firestore it would be great to update this lab to Firestore.

Stops working after few days

Hey guys!
Thanks for great tutorial it was really helpful to me and works well, except one moment... cloud function stops working after 3-4 days. Could someone tell me what could be the reason of this?

Thanks in advance

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.