我到处搜索过,相关文档已经过时(此处的页面显示了早期版本的 Google .net api 的示例:https://developers.google.com/youtube/v3/code_samples/dotnet https://developers.google.com/youtube/v3/code_samples/dotnet)
我正在尝试创建一个用于可恢复上传到 YouTube 的应用程序。我在 Google API 控制台上注册了我的应用程序,并拥有我的客户端密钥和客户端 ID。这是我用来验证的方法:
UserCredential credential;
using (FileStream stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new[] { YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeUpload },
"[my_username]", CancellationToken.None,
new FileDataStore("YouTube.ListMyLibrary"));
}
该进程挂在等待调用上。 client_secrets.json 文件加载得很好(单独测试过)。但是,当调用 AuthorizeAsync 时,我在挂起之前得到以下输出:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.Threading.Tasks.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.Threading.Tasks.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
我完全不知道它在寻找什么文件。我看过其他几个示例,但我完全不知道如何做到这一点。似乎没有明确的方法来使用 Youtube v3 api 进行身份验证。
任何帮助,将不胜感激!