javascript - 无需身份验证即可使用 Youtube API

标签 javascript oauth-2.0 google-api youtube-api pagekit

我正在尝试为 CMS 网站制作一个小部件,我可以在管理页面上对我的用户进行身份验证,然后显示下一个 YouTube 直播的计时器并从我的页面直接链接到它。

我已成功使用 youtube.liveBroadcasts.list API 并收到了我的广播列表并将其显示在页面上。但我希望能够在其他用户访问页面时在页面上显示此信息(关于我的 channel ),而无需登录或使用任何类型的身份验证。

最佳答案

我认为要使用来自 Youtube API 的此请求,需要登录。例如,当您将其粘贴到浏览器中时 LiveBroadcasts.list浏览器中的 URI 请求

https://www.googleapis.com/youtube/v3/liveBroadcasts

如果没有登录,您会收到错误消息:

"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization",

我认为阅读Implementing OAuth 2.0 Authorization也会有帮助。 .

以下是支持的 OAuth 流程:

  1. The server-side flow supports web applications that can securely store persistent information.
  2. The client-side flow supports JavaScript applications running in a browser.
  3. The installed application flow supports applications installed on a device, such as a phone or computer.
  4. The device flow supports devices with limited input capabilities, such as game consoles and video cameras.

*The service account flow supports server-to-server interactions that do not access user information. However, the YouTube Data API does not support this flow. Since there is no way to link a Service Account to a YouTube account, attempts to authorize requests with this flow will generate a NoLinkedYouTubeAccount error.

简而言之,我认为您需要获得授权才能执行此 API 调用。

关于javascript - 无需身份验证即可使用 Youtube API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40193529/

相关文章:

javascript - 如何删除json中不需要的编码符号

javascript - react 中查询为空时显示的项目

google-api - 为 Google Calendar v3 API 发出批量请求的端点是什么

android - 安装在 Android 设备中的已发布 APK 被 Play Protect 错误阻止

javascript - 用于隐藏/显示菜单的外部 JavaScript 不起作用

asp.net - 移动应用程序 Web API 身份验证

cordova - Ionic 4 oauth 重定向连接被拒绝

api - LinkedIn 的访问 token 更新流程可以在服务器上执行吗?

java - 获取配置文件时出现 Google Analytics API 证书异常

javascript - select2 from append 不起作用