I am facing the following problem: I have created a google service account and now I am trying make an authorized API call using c# to Google API and YouTube Data API. Here is my sample code:
string filePath = @"~\my-path\Default-GASvcAcct-508d097b0bff.json"
using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
googleCredential = GoogleCredential.FromStream(stream);
}
if (googleCredential.IsCreateScopedRequired)
{
googleCredential.CreateScoped(
new string[]
{
YouTubeService.Scope.YoutubeReadonly,
YouTubeService.Scope.YoutubeUpload,
YouTubeService.Scope.Youtube,
YouTubeService.Scope.YoutubeForceSsl,
YouTubeService.Scope.Youtubepartner,
YouTubeService.Scope.YoutubepartnerChannelAudit
});
}
YouTubeService service = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = googleCredential,
});
service.Videos.List()
The code builds successfully but when I start the program, I get the following error message:
System.IO.FileNotFoundException: 'Could not load file or assembly 'BouncyCastle.Crypto, Version=1.7.4137.9688, Culture=neutral, PublicKeyToken=a4292a325f69b123' or one of its dependencies. The system cannot find the file specified.'
Does somebody know how to fix this error and also, is it possible to make request to YouTube Data API with service account credentials?
Thanks in advance!