googlecodelabs / gcf-gmail-codelab

Apache License 2.0
19 stars 18 forks source link

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

Open kbroughton opened 2 years ago

kbroughton commented 2 years ago

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.

pavitra15 commented 2 years ago

Even i had same issue but it was solved by adding GCP_PROJECT in Runtime environment variables in cloud functions

amurciasu commented 2 years ago

You got this error because you are running this on a higher version of node8, adding GCP_PROJECT (in the auth and watch function/s) with value the gcloud project in the env variables (env_vars.yaml file in this case) should be fixed.

for the next problem you will see, you will need this info https://github.com/googlecodelabs/gcf-gmail-codelab/issues/17#issuecomment-1039137404

weynhamz commented 1 year ago

GCP Node10 runtime introduced some environment variable changes which require modifications of the source code.