Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Out-of-date channel names are displayed when authorizing via the YouTube Data API

$
0
0

While testing the app, I noticed that when logging in, the channel names were displayed as outdated. That is, the channels have been renamed, but their old names are still being displayed. In the screenshot, I showed what is being displayed and what the channels are actually named now. My question is, how can I make sure that the current channel names are displayed when authorizing?

# import necessary librariesimport google_auth_oauthlib.flowimport googleapiclient.discoveryimport googleapiclient.errors# set up the credentials for the userCLIENT_SECRETS_FILE = 'client_secrets.json'SCOPES = ['https://www.googleapis.com/auth/youtube.force-ssl']flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)credentials = flow.run_local_server(port=0)# create an instance of the YouTube API clientyoutube = googleapiclient.discovery.build('youtube', 'v3', credentials=credentials)# retrieve the channels that the user is authorized to accesschannels_request = youtube.channels().list(    mine=True,    part='id,snippet')channels_response = channels_request.execute()# print the available channelsfor channel in channels_response['items']:    print(channel['snippet']['title'], ':', channel['id'])# prompt the user to enter the video file pathvideo_file_path = input('Enter the file path of the video you want to upload: ')# create the video resource objectvideo_data = {'snippet': {'title': 'My Video Title','description': 'My Video Description','categoryId': '22'    },'status': {'privacyStatus': 'private'    }}video_resource = youtube.videos().insert(    part='snippet,status',    body=video_data,    media_body=googleapiclient.http.MediaFileUpload(video_file_path))# execute the video upload requestvideo_response = video_resource.execute()# print the video upload responseprint(video_response)

To further explain, this script runs by Python. Browser opens and first I am prompted to select an Google account from the list. After that, I am prompted to select the channel name (youtube account name), and finally, the video is uploaded to YouTube. Authorization is done using Google API libraries for Python (I do not open the browser myself).

enter image description here

Well, how to fix the display of old channel names?


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>