3
我需要使用YouTube API V3如何使用Youtube API查找实况视频列表?
来自任何渠道的现场活动列表我加入了官方的NuGet包到我的WPF项目:
使用Google.Apis.Auth.OAuth2;使用Google.Apis.Services的 ; 使用Google.Apis.Util.Store; 使用Google.Apis.YouTube.v3;
和我在一个按钮,点击添加OAuth认证:
UserCredential credential;
using (var stream = new FileStream("mydowloadedjsonfile.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets, new[] { YouTubeService.Scope.YoutubeReadonly }, "user",
CancellationToken.None, new FileDataStore("YouTubeAPI")
).Result;
}
var service = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "YouTubeAPI"
});
此代码的伟大工程,它会打开一个浏览器来得到验证,并允许YouTube的权限,以我的用户
之后,我想拿到现场活动的清单,但我failling:
var request = service.Search.List("snippet");
request.Q = "live event";//I know this is wrong...
request.MaxResults = 10;
var response = request.Execute();
东北角我做错了,可有人指向正确的方向吗?