首页 > 解决方案 > 使用 Youtube Data API V3 获取直播健康状态

问题描述

我可以通过我的 GSuite 邮件 ID xxxx@xxxx.com 访问 Youtube 频道。我正在使用 Youtube Data API V3 列出链接到该频道的直播流。(https://developers.google.com/youtube/v3/live/docs/liveStreams)但是,当我尝试使用它时,我收到以下消息:“使用 Google 登录暂时禁用此应用程序此应用程序有尚未经过 Google 验证才能使用 Google 登录。”

你能告诉我如何解决这个问题吗?

SCOPES = ['https://www.googleapis.com/auth/youtube.readonly']
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'

def get_authenticated_service():
  try:
    flow = flow_from_clientsecrets(CLIENT_SECRETS_FILE, scope=SCOPES, message="")
    storage = Storage(CLIENT_AUTH_FILE)
    credentials = storage.get()
    if credentials is None or credentials.invalid:
      credentials = run_flow(flow, storage, args)
    return build(API_SERVICE_NAME, API_VERSION, http=credentials.authorize(httplib2.Http()))
  except Exception as e:
    logger.info("ERROR: Exception from get_authenticated_service. " + str(e))

# Retrieve a list of the liveStream resources associated with the currently
# authenticated user's channel.
def list_streams(youtube):
    list_streams_request = youtube.liveStreams().list(
      # part='id,snippet,status',
      part='snippet,status',
      mine=True,
      maxResults=50
    )
    if list_streams_request:
      list_streams_response = list_streams_request.execute()

if __name__ == '__main__':
  youtube = get_authenticated_service()
  list_streams(youtube)

标签: pythonyoutubeyoutube-apiyoutube-data-apiyoutube-livestreaming-api

解决方案


推荐阅读