Reputation: 61
The code doesn't give any errors but on the youtube page there is nothing. The token is ok and I can see the log saying it has finished but on youtube nothing. How much time it take to display the video on youtube?
const Youtube = require("youtube-api"),
fs = require("fs"),
readJson = require("r-json"),
Logger = require("bug-killer"),
prettyBytes = require("pretty-bytes");
// I downloaded the file from OAuth2 -> Download JSON
const CREDENTIALS = readJson(`${__dirname}/credentials.json`);
// Authenticate
let oauth = Youtube.authenticate({
type: "oauth",
client_id: CREDENTIALS.web.client_id,
client_secret: CREDENTIALS.web.client_secret,
redirect_url: CREDENTIALS.web.redirect_uris[0]
});
//the token obtained with getToken.js script
var tokens = readJson(`${__dirname}/tokens.json`);
//set the token
oauth.setCredentials(tokens);
var req = Youtube.videos.insert({
resource: {
snippet: {
title: "Testing",
description: "Test video upload via YouTube API"
},
status: {
privacyStatus: "public"
}
},
part: "snippet,status",
media: {
body: fs.createReadStream("video.mp4")
}
}, (err, data) => {
console.log("Done.");
process.exit();
});
setInterval(function() {
Logger.log(`${prettyBytes(req.req.connection._bytesDispatched)} bytes uploaded.`);
}, 250);
Upvotes: 0
Views: 112
Reputation: 61
Resolved, you have to enable the youtube Api v3 for your google app. Stupid issue.
Upvotes: 2