I have tried to create a sample program using Node.js, following instructions from https://developers.google.com/google-apps/activity/v1/quickstart/nodejs
I throws an error saying cannot read property 'client_secret' of undefined when trying to run it.
Looking for your valuable suggestions.
Thanks in advance.
var clientSecret = credentials.installed.client_secret;
In this line credentials is pointing to client_secret.json so the first key has to be "installed". In my case the key was "web" and that was causing the error. I just renamed the key "web" to "installed".
Since there is no key named "installed", it's parsing it to be undefined.
In credentials.json change the key "web" to "installed". Probably the docs need to change from Google's side.



It seems you have missed Step 1: Turn on the Google Apps Activity API.
After creating the Credentials:
f. Click the file_download (Download JSON) button to the right of the client ID.
g. Move this file to your working directory and rename it client_secret.json. Put it in your project folder.
Your client_secret.json file needs to have the line below:
"redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"]
instead of the lines like below:
"javascript_origins":
[
"http://localhost:8080",
"http://localhost:1453",
"http://127.0.0.1:1453",
"http://localhost"
]
Also you may want to change chain head in client_secret.json from web to installed, or vise versa.
I had this problem, but I had the wrong type of credentials file. I initially used "Web Server (Nodejs)...", and it had the "web" heading instead of the "installed", but when I did it again, and selected "Windows UI (cmd line)", I got the file with the correct format.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With