Youtube API:Python 搜索不起作用,导致应用程序默认凭据不可用



尝试使用以下代码搜索YouTube视频:https://github.com/youtube/api-samples/blob/master/python/search.py

但是无论我尝试什么,即使我提供了 api 密钥,我也会出现以下错误:

Traceback (most recent call last):
  File "search.py", line 56, in <module>
    youtube_search(args)
  File "search.py", line 18, in youtube_search
    developerKey=DEVELOPER_KEY)
  File "C:Python27Scriptstvapp_envlibsite-packagesoauth2client_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:Python27Scriptstvapp_envlibsite-packagesgoogleapiclientdiscovery.py", line 226, in build
    credentials=credentials)
  File "C:Python27Scriptstvapp_envlibsite-packagesoauth2client_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:Python27Scriptstvapp_envlibsite-packagesgoogleapiclientdiscovery.py", line 358, in build_from_document
    credentials = _auth.default_credentials()
  File "C:Python27Scriptstvapp_envlibsite-packagesgoogleapiclient_auth.py", line 40, in default_credentials
    return oauth2client.client.GoogleCredentials.get_application_default()
  File "C:Python27Scriptstvapp_envlibsite-packagesoauth2clientclient.py", line 1264, in get_application_default
    return GoogleCredentials._get_implicit_credentials()
  File "C:Python27Scriptstvapp_envlibsite-packagesoauth2clientclient.py", line 1254, in _get_implicit_credentials
    raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.

请帮忙,我从窗口机器运行它。或者有更好的代码来进行YouTube搜索。

谢谢

似乎您没有在谷歌应用引擎或谷歌计算引擎中运行该应用程序。因此,不会有任何默认凭据可供使用,因此您必须首先从Google开发人员控制台下载凭据,然后在应用程序中使用这些凭据。有关更多详细信息,请参阅此文档。

相关内容

  • 没有找到相关文章

最新更新