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

Youtube API v3 : access youtube videos using service account

$
0
0

I am trying to use Google Service Account to list videos from YouTube Data API v3 in .NET. I have activated YouTube API, created Account Service, but whenever I am trying to list videos from my channel, it says 0 videos even if I do have uploaded videos. Could you please help ? Thanks.

Here is the code -

string[] scopes = new string[] {        YouTubeAnalyticsService.Scope.YtAnalyticsReadonly,     YouTubeAnalyticsService.Scope.YtAnalyticsMonetaryReadonly, "https://www.googleapis.com/auth/youtube.force-ssl"};// service account credentialGoogleCredential credential = GoogleCredential.FromFile(SecretPath).CreateScoped(scopes);var youtubeService = new YouTubeService(new BaseClientService.Initializer(){    HttpClientInitializer = credential,    ApplicationName = channelinfo.AnalyticsAPIFileDataStore});Dictionary<string, DateTime?> videoIds = new Dictionary<string, DateTime?>();var channelResourcesList = youtubeService.Channels.List("contentDetails");channelResourcesList.Id = channelinfo.ChannelId;var listResult = channelResourcesList.Execute();string playListId = listResult.Items[0]?.ContentDetails.RelatedPlaylists.Uploads;var listOfVideos = youtubeService.PlaylistItems.List("snippet");listOfVideos.PlaylistId = playListId;var nextPageToken = "";while (nextPageToken != null){    listOfVideos.MaxResults = 50;    listOfVideos.PageToken = nextPageToken;    // searchresult is empty (listOfVideos.Execute() returns empty result) although channelResourcesList.Execute() worked    var searchListResult = listOfVideos.Execute();    nextPageToken = searchListResult.NextPageToken;}

Viewing all articles
Browse latest Browse all 3720

Latest Images

Trending Articles



Latest Images

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