【问题标题】:Youtube Data API: Python Quickstart: Authorisation URL is 'Not Verified by Google'Youtube 数据 API:Python 快速入门:授权 URL 为“未经 Google 验证”
【发布时间】:2020-06-08 13:20:56
【问题描述】:

enter image description here

作为示例 python 程序输出的授权 URL:https://developers.google.com/youtube/v3/docs/channels/list?apix=true 引导我到一个网页。它说:“此应用程序未经 Google 验证”。需要帮助。

【问题讨论】:

  • 给定的图片是问题的截图。
  • 嗨,Mappy,欢迎您。我刚刚尝试了 Firefox 上的链接,它工作得很好。也许尝试其他浏览器。您还可以尝试清除当前浏览器缓存。下次尝试提供更多信息,例如您使用的操作系统、浏览器、您尝试解决问题的方法等。

标签: youtube-api youtube-data-api


【解决方案1】:

欢迎,Mappy,您需要在 Google Cloud Platform 中创建凭据,您会在此处获得一个 token as client 用于预生产任务和有限的同意屏幕。准备就绪后,您的应用需要通过 Google 验证(Auth Consent ScreenOAuth Scopes for Google)。

# -*- coding: utf-8 -*-

# Sample Python code for youtube.channels.list
# See instructions for running these code samples locally:
# https://developers.google.com/explorer-help/guides/code_samples#python

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 = "youtube"
    api_version = "v3"
    client_secrets_file = "YOUR_CLIENT_SECRET_FILE.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()
    youtube = googleapiclient.discovery.build(
        api_service_name, api_version, credentials=credentials)

    request = youtube.channels().list(

    )
    response = request.execute()

    print(response)

if __name__ == "__main__":
    main()

终端中的最低限度测试对我有用。

curl \
  'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=Me%20dicen%20Dai&key=[YOUR_API_KEY]' \
  --header 'Accept: application/json' \
  --compressed

【讨论】:

    【解决方案2】:

    在 google 的 Oauth Consent Screen 配置中添加范围,如果您选择的范围需要验证,它将显示一个橙色三角形。

    此错误的原因是因为许多 Google 范围需要应用程序验证才能与外部用户一起使用。

    此外,此 url 将告诉您请求的范围是否可能属于敏感或受限类别

    https://support.google.com/cloud/answer/9110914?hl=en

    【讨论】:

    • 但是当我提交验证时,它要求强制性的应用程序主页链接,以及应用程序隐私政策链接。但我都没有。请帮忙。
    • :) 你必须提供这个才能继续前进。您可以异步执行此操作,并在验证过程中对开发进行排序
    猜你喜欢
    • 2012-01-03
    • 1970-01-01
    • 1970-01-01
    • 2018-06-13
    • 2017-11-19
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多