将youtube livestream API与youtube合作伙伴渠道

时间:2017-04-29 05:25:21

标签: youtube-api youtube-data-api

我永远难以接受这一点。我有一个youtube频道,其中,我是所有者。我一直在使用OAuth2并对我的所有者帐户进行身份验证,然后通过以下访问域提供对我的YouTube帐户的访问权限

https://www.googleapis.com/auth/youtubepartner, https://www.googleapis.com/auth/youtube.force-ssl, https://www.googleapis.com/auth/youtube.readonly, https://www.googleapis.com/auth/youtube 

我在python google api界面中使用各种参数发出youtube.liveStreams().list命令,但我从来没有得到有用的信息。

我目前有一个未列出的流正在运行,DsjbycJHosw。

list_streams_request = youtube.liveStreams().list( part="snippet", id="DsjbycJHosw" )` responds with `{'etag': '"m2...gE"', 'kind': 'youtube#liveStreamListResponse', 'items': [], 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}

list_streams_request = youtube.liveStreams().list( part="snippet", mine="true" )` responds with `{'etag': '"m2...gE"', 'kind': 'youtube#liveStreamListResponse', 'items': [], 'pageInfo': {'totalResults': 0, 'resultsPerPage': 5}}

list_streams_request = youtube.liveStreams().list( part="snippet", broadcastStatus="all" )给了我一个python错误。看起来Python API不支持它。 TypeError: Got an unexpected keyword argument "broadcaststatus

list_streams_request = youtube.liveStreams().list( part="snippet", onBehalfOfContentOwner="[Channel Youtube UserID (base64)]" )` responds with `b'{\n "error": {\n  "errors": [\n   {\n    "domain": "youtube.parameter",\n    "reason": "missingRequiredParameter",\n    "message": "No filter selected. Expected one of: mine, id, default",\n    "locationType": "parameter",\n    "location": ""\n   }\n  ],\n  "code": 400,\n  "message": "No filter selected. Expected one of: mine, id, default"\n }\n}\n'

好的,所以,我需要与我的频道ID一起提供一些东西,对吧?让我们添加一个"我的" =真。

list_streams_request = youtube.liveStreams().list( part="snippet", onBehalfOfContentOwner="[Channel Youtube User ID(base64)]", mine="true" )` responds with `b'{\n "error": {\n  "errors": [\n   {\n    "domain": "youtube.parameter",\n    "reason": "invalidMine",\n    "message": "The \\u003ccode\\u003emine\\u003c/code\\u003e parameter cannot be used in requests where the authenticated user is a YouTube partner. You should either remove the \\u003ccode\\u003emine\\u003c/code\\u003e parameter, authenticate as a YouTube user by removing the \\u003ccode\\u003eonBehalfOfContentOwner\\u003c/code\\u003e parameter, or act as one of the partners channels by providing the \\u003ccode\\u003eonBehalfOfContentOwnerChannel\\u003c/code\\u003e parameter if available for the called method.",\n    "locationType": "parameter",\n    "location": "mine"\n   }\n  ],\n  "code": 400,\n  "message": "The \\u003ccode\\u003emine\\u003c/code\\u003e parameter cannot be used in requests where the authenticated user is a YouTube partner. You should either remove the \\u003ccode\\u003emine\\u003c/code\\u003e parameter, authenticate as a YouTube user by removing the \\u003ccode\\u003eonBehalfOfContentOwner\\u003c/code\\u003e parameter, or act as one of the partners channels by providing the \\u003ccode\\u003eonBehalfOfContentOwnerChannel\\u003c/code\\u003e parameter if available for the called method."\n }\n}\n'

真的?来吧,API先生。如果我使用onBehalfOfContentOwnerChannel怎么办?

list_streams_request = youtube.liveStreams().list( part="snippet", onBehalfOfContentOwnerChannel="[My base64 channel ID]" )` yeilds `b'{\n "error": {\n  "code": 500,\n  "message": null\n }\n}\n' 

我能想到的每一个组合都给了我大量的错误代码500&#39。

我似乎也无法在python API中设置forContentOwner,所以没有骰子。一个人应该如何做到这一点?

1 个答案:

答案 0 :(得分:0)

这不再是问题。截至2018年1月,他们已经解决了这个问题。现在,API的行为完全符合预期,因为youtube合作伙伴可以执行oauth权限。