Reputation: 4225
I've just copied a simple example from Youtube docs but it fails. I want to implement Youtube data API in my project.
Following these links:
Youtube data api quickstart documentation
Youtube data api quickstart github repo
"client_secret.json"
fileBut when I run this script an error occurs:
~/workspace/youtube/quickstart $ node test-1.js
/home/ubuntu/workspace/youtube/quickstart/test-1.js:31
var clientSecret = credentials.installed.client_secret;
^
TypeError: Cannot read property 'client_secret' of undefined
at authorize (/home/ubuntu/workspace/youtube/quickstart/test-1.js:31:43)
at processClientSecrets (/home/ubuntu/workspace/youtube/quickstart/test-1.js:20:3)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:446:3)
Where did I possibly make a mistake and how to fix it?
Upvotes: 2
Views: 235
Reputation: 447
Please check you json file. If your json file start with {web:{client...
you have chosen to create credentials for a Web application and this example won't work unless you change "installed" to "web"on your code.
The example is set to work perfectly if you choose to create credentials for a computer application. Then it will generate a json file with "installed".
Upvotes: 0
Reputation: 3204
The issue is with the client_secret json file. Try parsing the json using some online json parser. Since the parsing failed or could not find json file at the specificed location the credentials variable is undefined. Js engine throws error as it couldn't read client_secret of undefined.
Upvotes: 1