YouTubeAPI-Examples icon indicating copy to clipboard operation
YouTubeAPI-Examples copied to clipboard

ValueError: Credentials from google.auth specified, but google-api-python-client is unable to use these credentials unless google-auth-httplib2 is installed. Please install google-auth-httplib2.

Open shahinesi opened this issue 4 years ago • 1 comments

how to fix this error? ValueError: Credentials from google.auth specified, but google-api-python-client is unable to use these credentials unless google-auth-httplib2 is installed. Please install google-auth-httplib2.

my code

import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request

api_key = "AIzaSyB2SHypuzoHEUHANB_EDDsfsdfsdfTfMNvC1sI"
CLIENT_SECRET_FILE = "client_secret_99925415505-a7ge726hs7fhilhcbt3b4lp374d9juc4.apps.googleusercontent.com.json"
#SCOPES = ['https://www.googleapis.com/auth/youtube']
SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"]

flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
credentials = flow.run_console()
youtube = build('youtube', 'v3', credentials=credentials)
Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=99925415505-a7ge726hs7fhilhcbt3b4lp374d9juc4.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.force-ssl&state=cYmJ4vyTCj9x4Oj5uHZM9GeLvjkWWY&prompt=consent&access_type=offline
Enter the authorization code: 4/3gG9HcS_iJK8t3DkL0pq3ESU15byXE7DoyETebe1ok9rL3DjRrkF458
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-47-2b1a50b26faf> in <module>
      1 flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
      2 credentials = flow.run_console()
----> 3 youtube = build('youtube', 'v3', credentials=credentials)

~\Anaconda3\lib\site-packages\oauth2client\_helpers.py in positional_wrapper(*args, **kwargs)
    131                 elif positional_parameters_enforcement == POSITIONAL_WARNING:
    132                     logger.warning(message)
--> 133             return wrapped(*args, **kwargs)
    134         return positional_wrapper
    135 

~\Anaconda3\lib\site-packages\googleapiclient\discovery.py in build(serviceName, version, http, discoveryServiceUrl, developerKey, model, requestBuilder, credentials, cache_discovery, cache)
    230       More details on the environment variables are here:
    231       https://google.aip.dev/auth/4114
--> 232     adc_cert_path: str, client certificate file path to save the application
    233       default client certificate for mTLS. This field is required if you want to
    234       use the default client certificate. `GOOGLE_API_USE_CLIENT_CERTIFICATE`

~\Anaconda3\lib\site-packages\oauth2client\_helpers.py in positional_wrapper(*args, **kwargs)
    131                 elif positional_parameters_enforcement == POSITIONAL_WARNING:
    132                     logger.warning(message)
--> 133             return wrapped(*args, **kwargs)
    134         return positional_wrapper
    135 

~\Anaconda3\lib\site-packages\googleapiclient\discovery.py in build_from_document(service, base, future, http, developerKey, model, requestBuilder, credentials)
    373     return content
    374 
--> 375 
    376 @positional(1)
    377 def build_from_document(

~\Anaconda3\lib\site-packages\googleapiclient\_auth.py in authorized_http(credentials)
     95         if google_auth_httplib2 is None:
     96             raise ValueError(
---> 97                 "Credentials from google.auth specified, but "
     98                 "google-api-python-client is unable to use these credentials "
     99                 "unless google-auth-httplib2 is installed. Please install "

ValueError: Credentials from google.auth specified, but google-api-python-client is unable to use these credentials unless google-auth-httplib2 is installed. Please install google-auth-httplib2.

shahinesi avatar Sep 04 '20 06:09 shahinesi

Open the terminal, run

pip install google-auth-httplib2

That should fix the error.

maleksware avatar Mar 28 '21 05:03 maleksware