cannot read property 'client_secret' of undefined

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.

Before

enter image description here

After

enter image description here


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".


enter image description here

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.