Cannot read client_secret property from undefined

I tried to create a sample program using Node.js, following the instructions from https://developers.google.com/google-apps/activity/v1/quickstart/nodejs

I throw an error message: cannot read the client_secret property from undefined when trying to start it.

Search for your valuable suggestions.

Thanks in advance.

+7
google-drive-sdk
source share
5 answers

var clientSecret = credentials.installed.client_secret; On this line, the credentials point to client_secret.json , so the first key must be "set." In my case, the key was "web", and this caused an error. I just renamed the key "web" to "installed."

+4
source share

enter image description here

You seem to have skipped Step 1: Turn on the Google Apps Activity API .

After creating the credentials:

f. Click the file_download button (Download JSON) to the right of the client ID.

d. Move this file to the working directory and rename it client_secret.json. Put it in the project folder.

+3
source share

Your client_secret.json file should have the following line:

 "redirect_uris": ["urn:ietf:wg:oauth:2.0:oob", "http://localhost"] 

instead of lines as below:

 "javascript_origins": [ "http://localhost:8080", "http://localhost:1453", "http://127.0.0.1:1453", "http://localhost" ] 

You can also change the chain in client_secret.json from web to installed or vice versa.

0
source share

I had this problem, but I had the wrong credential file type. At first I used "Web server (Nodejs) ..." and it had a "web header" instead of "installed", but when I did it again and selected "Windows UI (cmd line)", I got a file with the correct format.

0
source share

Since there is no key with the name "installed", it analyzes it to be undefined .

In credentials.json change the "web" key to "installed". Possibly, documents should change from Google.

Before

enter image description here

After

enter image description here

0
source share

All Articles