2016-10-22 46 views
0

我正在嘗試爲CMS網站製作一個小部件,我可以在管理頁面上對我的用戶進行身份驗證,然後在下一個YouTube直播中顯示計時器並直接從我的頁面鏈接到它。使用Youtube API而無需身份驗證

我已經成功地使用了youtube.liveBroadcasts.list api,並收到了我的廣播列表並在頁面上顯示。但我希望能夠在其他用戶訪問該頁面時在頁面上顯示此信息(關於我的頻道),而無需登錄或使用任何類型的身份驗證。

回答

1

我認爲要使用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調用。