Youtube api 创建实时广播时出错-NodeJS libs

Youtube api 创建实时广播时出错-NodeJS libs,youtube-api,youtube-data-api,youtube-livestreaming-api,Youtube Api,Youtube Data Api,Youtube Livestreaming Api,我正在尝试使用nodejs客户端库创建实时广播,但出现以下错误: { Error: Title is required at Request._callback code: 400, . . . errors: [ { domain: 'youtube.liveBroadcast', reason: 'titleRequired', message: 'Title is required', extendedHelp: 'http

我正在尝试使用nodejs客户端库创建实时广播,但出现以下错误:

{ Error: Title is required
    at Request._callback   code: 400,
.
.
.
  errors: 
   [ { domain: 'youtube.liveBroadcast',
       reason: 'titleRequired',
       message: 'Title is required',
       extendedHelp: 'https://developers.google.com/youtube/v3/live/docs/liveBroadcasts/insert#request_body' } ] }
它在API浏览器上工作,这让我迷路了。以下是代码:

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var youtube = google.youtube('v3');

var oauth2Client = new OAuth2(
  'xxxx', //CLIENT_ID
  'xxxx', //MY_CLIENT_SECRET,
  'http://localhost:3000/api/integrations/youtube'//YOUR_REDIRECT_URL
);

oauth2Client.setCredentials({
  access_token: "xxxx",
  refresh_token: "xxxx"

});

broadcastParams = {
    "auth": oauth2Client,
    "part": "snippet,status,contentDetails",
    "snippet": {
        "title": "Testing NodeJS",
        "scheduledStartTime": "2017-02-20T14:00:00.000Z",
        "scheduledEndTime": "2017-02-20T15:00:00.000Z",
    },
    "status": {
        "privacyStatus": "private",
    },
    "contentDetails": {
        "monitorStream": {
            "enableMonitorStream": true,
        }
    }
};


youtube.liveBroadcasts.insert(broadcastParams,  
function(err,broadcast) {
    if (err) {
        return console.log('Error creating broadcast: ', err);
    }
    console.log('Broadcast = ' + JSON.stringify(broadcast));
});
谢谢你的帮助

解决了

我的广播参数不正确。我错过了“资源”。以下是目前正在运行的代码:

var google = require('googleapis');
var OAuth2 = google.auth.OAuth2;
var youtube = google.youtube('v3');

var oauth2Client = new OAuth2(
  'xxxx', //CLIENT_ID
  'xxxx', //MY_CLIENT_SECRET,
  'http://localhost:3000/api/integrations/youtube'//YOUR_REDIRECT_URL
);

oauth2Client.setCredentials({
  access_token: "xxxx",
  refresh_token: "xxxx"

});

broadcastParams = {
    "auth": oauth2Client,
    "part": "snippet,status,contentDetails",
    "resource": {
        "snippet": {
            "title": "Tesing NodeJS 123",
            "scheduledStartTime": "2017-02-20T14:00:00.000Z",
            "scheduledEndTime": "2017-02-20T15:00:00.000Z",
        },
        "status": {
            "privacyStatus": "private",
        },
        "contentDetails": {
            "monitorStream": {
                "enableMonitorStream": true,
            }
        }
    }
};


youtube.liveBroadcasts.insert(broadcastParams,  function(err,broadcast) {
    if (err) {
        return console.log('Error creating broadcast: ', err);
    }
    console.log('Broadcast = ' + JSON.stringify(broadcast));
});

我在项目本身中打开了一个bug。以下是后续链接: