'I'm Having Trouble With Youtube Rating API

I want to vote for a video with youtube rate api. When I run the code below, it shows as liked the video, but the number of likes does not increase. The number of likes does not seem to increase when someone else looks at it or when I open it from the incognito window.

import argparse
import os
import re

import google.oauth2.credentials
import google_auth_oauthlib.flow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
from google_auth_oauthlib.flow import InstalledAppFlow

CLIENT_SECRETS_FILE = 'client_secret.json'
SCOPES = ['https://www.googleapis.com/auth/youtube']
API_SERVICE_NAME = 'youtube'
API_VERSION = 'v3'

RATINGS = ('like')

def get_authenticated_service():
  flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
  credentials = flow.run_console()
  return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)

def like_video(youtube, args):
  youtube.videos().rate(
  id=args.videoId,
  rating=args.rating
  ).execute()

if __name__ == '__main__':
  parser = argparse.ArgumentParser()
  parser.add_argument('--videoId', default='4CAf5YxOolc',
  help='ID of video to like.')
  parser.add_argument('--rating', default='like',
  choices=RATINGS,
  help='Indicates whether the rating is "like", "dislike", or "none".')
  args = parser.parse_args()

  youtube = get_authenticated_service()
  try:
    like_video(youtube, args)
  except:
    print('An HTTP error %d occurred:\n%s' % (e.resp.status, e.content))
  else:
    print ('The %s rating has been added for video ID %s.' %
           (args.rating, args.videoId))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source