Python: How do I resolve oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available?

david.amadi at digital.beis.gov.uk david.amadi at digital.beis.gov.uk
Sat Feb 4 18:39:04 EST 2017


Hello All,

I’m a newbie to python programming – got into it predominately for the purposes of machine learning and data mining and even though I’ve committed several weeks to learning the scripting language, I have struggled to fully grasp how it works.

I’m looking to scrape title, video Id, view Count, like Count, dislike Count, comment Count, favourite Count etc off YouTube using a python script I found via an online tutorial.

I have installed ‘unidecode’ and 'google-api-python-client' packages via my terminal. I have also enabled YouTube Data Api V3 and I’m getting the error below each time I run the script. 

Could anyone please point me in the right direction?

Thanks a lot in advance for your help

****
Traceback (most recent call last):
  File "/Users/*Path*/ML with Python/youtube_search.py", line 73, in <module>
    youtube_search(args)
  File "/Users/*Path*/ML with Python/youtube_search.py", line 21, in youtube_search
    youtube = build(YOUTUBE_API_SERVICE_NAME, YOUTUBE_API_VERSION, developerKey=DEVELOPER_KEY)
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py", line 226, in build
    credentials=credentials)
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/discovery.py", line 358, in build_from_document
    credentials = _auth.default_credentials()
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/googleapiclient/_auth.py", line 41, in default_credentials
    return oauth2client.client.GoogleCredentials.get_application_default()
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/client.py", line 1264, in get_application_default
    return GoogleCredentials._get_implicit_credentials()
  File "/Users/*Path*/anaconda/lib/python3.5/site-packages/oauth2client/client.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.

-- 
Communications with the Department for Business, Innovation and Skills may 
be automatically logged, monitored and/or recorded for legal purposes.



More information about the Python-list mailing list