youtube API not creating a playlist

Viewed 28

I get no error codes; everything seems to be validating correctly etc but simply nothing is happening on the YouTube channel. I have exceeded my limit rate so something has to be happening, but nothing that i can actually see. My code as follows

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

credentials = None #sets credentials to none

if os.path.exists('token.pickle'): #checks for our pickle file and opens it if it exists
    print('loading credentials from file...')
    with open('token.pickle', 'rb') as token: #rb opens byte file
        credentials = pickle.load(token) #loads our information(token) from pickle
#validates the credentials, if none are found makes and finds the credentials
if not credentials or not credentials.valid:
    if credentials and credentials.expired and credentials.refresh_token:
        print('refreshing access token...')
        credentials.refresh(Request())
    else:
        print('fetching new tokens...')
        flow = InstalledAppFlow.from_client_secrets_file('client_secrets.json', scopes=['https://www.googleapis.com/auth/youtube.force-ssl', 'https://www.googleapis.com/auth/youtube'])
        flow.run_local_server(port=8080, prompt='consent', authorization_prompt_message='')
        credentials = flow.credentials

        #saves credentials for next run
        with open('token.pickle', 'wb') as f:
            print("saving credentials for future use...")
            pickle.dump(credentials, f)

#builds youtube and validates our credentials
youtube = build('youtube', "v3", credentials=credentials)
playlist_name = str(input('name of playlist: '))

#makes the playlist
requests = youtube.playlists().insert(
        part="snippet,status",
        body={
          "snippet": {
            "title": playlist_name,
            "description": "This is a sample playlist description.",
            "tags": [
              "sample playlist",
              "API call"
            ],
            "defaultLanguage": "en"
          },
          "status": {
            "privacyStatus": "public"
          }
        }
        )


response = requests.execute()

print(response)
0 Answers
Related