YouTube分析API授权问题?
我为我的雇主的组织YouTube频道提供分析服务。我一直在使用YouTube数据API成功地检索数据,但是我无法从YouTube分析API(a'la reports.query)获取指标 以下是详细情况。。。 身份验证:SAML(组织GSuite帐户) 授权:OAuth2 我的组织帐户是YouTube频道的“所有者”(但不是主要所有者)。 谷歌云平台项目:内部(组织) 我尝试过各种范围组合 当我指定ids=“channel==”时,我收到一个403(禁止)响应 当我指定ids=“channel==MINE”时,我会得到一个带有标题的200状态,但取决于维度和度量选择,要么没有记录,要么每个度量都有一个带零的记录。我怀疑“channel==My”是在寻找“My”频道,而不是品牌客户的频道,因为它不知道哪个品牌的频道 我的问题是,我如何确保我的组织帐户可以使用YouTube分析API以及YouTube报告API获取数据?是否有分配这些访问权限的管理站点?如果是,它在哪里 下面的代码基本上是来自API资源管理器的示例代码YouTube分析API授权问题?,api,youtube,authorization,analytics,no-data,Api,Youtube,Authorization,Analytics,No Data,我为我的雇主的组织YouTube频道提供分析服务。我一直在使用YouTube数据API成功地检索数据,但是我无法从YouTube分析API(a'la reports.query)获取指标 以下是详细情况。。。 身份验证:SAML(组织GSuite帐户) 授权:OAuth2 我的组织帐户是YouTube频道的“所有者”(但不是主要所有者)。 谷歌云平台项目:内部(组织) 我尝试过各种范围组合 当我指定ids=“channel==”时,我收到一个403(禁止)响应 当我指定ids=“channel=
import os
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
scopes = ["https://www.googleapis.com/auth/youtube.readonly"]
def main():
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtubeAnalytics"
api_version = "v2"
client_secrets_file = "client_secret.json"
# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
# credentials = flow.run_console()
credentials = flow.run_local_server()
youtube_analytics = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
request = youtube_analytics.reports().query(
ids="channel==MINE",
startDate="2020-09-01",
endDate="2020-09-30",
dimensions="day",
metrics="views",
)
response = request.execute()
print(response)
if __name__ == "__main__":
main()
如图所示的代码生成
{'kind':'youtubeeanalytics#resultable','columnheader':[{'name':'day','columnType':'DIMENSION','dataType':'STRING'},{'name':'views','columnType':'METRIC','dataType':'INTEGER'},'rows':[]
当ids设置为“channel==UC6L0DBYWqAkmwfawTUMaR3g”时,将返回以下内容
googleapiclient.errors.HttpError:
您解决了这个问题吗?我也有类似的问题。