Susaj S N
Susaj S N

Reputation: 1077

googleapiclient.errors.UnknownApiNameOrVersion: name: youtubePartner version: v1

I have been trying for youtube content api and tried with the following code

def main():
  
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
    filename='bbtv-306609-b20e12d67493.json',
    scopes=['https://www.googleapis.com/auth/youtubepartner',
    'https://www.googleapis.com/auth/youtube.force-ssl',
    'https://www.googleapis.com/auth/youtubepartner'])
  http = httplib2.Http()
  http = credentials.authorize(http)
  service = build("youtubePartner", version="v1", http=http)

ended up with.. Result

And i have added the following user under members

Google console

Upvotes: 3

Views: 3589

Answers (2)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116918

This is a basic example of authorization for python to Oauth2 based upon the tutorial found here

Remember you need to create service account credentials, enable the YouTube api under libraries.

"""Hello Youtube V3."""

from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials


SCOPES = ['https://www.googleapis.com/auth/youtubepartner',
'https://www.googleapis.com/auth/youtube.force-ssl',
'https://www.googleapis.com/auth/youtubepartner']
KEY_FILE_LOCATION = '<REPLACE_WITH_JSON_FILE>'
   

def initialize_youtube():
  """Initializes an youtube  V3 service object.

  Returns:
    An authorized youtube API V3 service object.
  """
  credentials = ServiceAccountCredentials.from_json_keyfile_name(
      KEY_FILE_LOCATION, SCOPES)

  # Build the service object.
  analytics = build('youtube', 'v3', credentials=credentials)

  return analytics




def main():
  analytics = initialize_analyticsreporting()


if __name__ == '__main__':
  main()

I am not a python dev you will need to add the remainder of your code to this this just shows you how the authorization works.

Upvotes: 0

KarolDepka
KarolDepka

Reputation: 8628

For me, adding static_discovery=False worked.

Upvotes: 7

Related Questions