javascript - YouTube API 归 Google+ 页面授权 Google Apps 脚本所有

标签 javascript google-apps-script youtube youtube-api google-apps

我正在尝试编写一个脚本,从我管理的一个 channel 获取所有已完成的 YouTube 直播,并将一些统计信息(观看次数等)写入 Google 电子表格。

我的 Google 帐户是几个 Google+ 信息页的管理器,其中一些信息页与 YouTube channel 相关联。据我所知,这些页面“拥有” channel 。

我将其放入Code.gs中:

function updateStats() {

  var liveEventsResponse = YouTube.LiveBroadcasts.list('snippet', {
      maxResults: 50,
      pageToken: nextPageToken
    });

  Logger.log(liveEventsResponse);

}

当我在脚本上运行函数时,我得到这个框:

YouTube Authorization Box

我点击我的 Google+ 信息页并得到以下信息:

YouTube Authorization Box 2

如果我点击“允许”并将脚本授权为我的 Google+ 信息页,该框就会关闭,一切看起来都正常。然而,一旦我尝试再次运行该函数,它就会弹出相同的框并再次询问我。

我的问题是:我可以使用 Google Apps 脚本中的 YouTube API 从 Google+ 信息页拥有的 YouTube channel 获取数据吗?

谢谢!

最佳答案

YouTube Service 中所述

The YouTube service allows you to use the YouTube Data API and YouTube Live Streaming API in Apps Script. This API gives users the ability to manage their videos, playlists, channels, and live events.

Please note that this is an advance service that must be enabled before use.

但是,对 Content ID API 的请求有一定的授权要求,这与授权其他 Live Streaming API 的要求不同。要求。正如文档中提到的,以下API有授权要求。

  • Calling the Data API

    The API request must be authorized by the Google Account that owns the broadcasting YouTube channel.

  • Calling the Content ID API

    The API request must be authorized by a Google Account that is linked to the content owner that owns the broadcasting YouTube channel.

请阅读文档以获取更多信息。

关于javascript - YouTube API 归 Google+ 页面授权 Google Apps 脚本所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38212656/

相关文章:

javascript - 用点填充两个文本元素之间的空间

javascript - 从 Outlook Office REST API 获取联系人计数 - Javascript

firebase - 如何从 Google 表格访问 Cloud Firestore?

google-apps-script - 使用 Google Apps 脚本删除 Google 表格中的行

javascript - 使用 Javascript 隐藏/取消隐藏 Flash 视频

facebook - 如何获得Facebook分享,评论,例如youtube视频计数?

javascript - 静音隐藏的 Youtube iframe .. JS 中的按钮 onclick 不起作用

javascript - 当项目添加到 DOM 或从 DOM 中删除时,是否有 JavaScript 事件?

javascript - 将附加内容插入欧芹错误

google-apps-script - 如何或在何处定义在多个电子表格中使用的函数?