具有多个youtube帐户的OAuth
我正在编写一个Windows桌面应用程序,将视频上传到youtube。我正在使用下面的代码具有多个youtube帐户的OAuth,oauth,youtube,Oauth,Youtube,我正在编写一个Windows桌面应用程序,将视频上传到youtube。我正在使用下面的代码 UserCredential credential; /* using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) { // dependent on the client_secrets.js
UserCredential credential;
/*
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
// dependent on the client_secrets.json file
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None
);
}*/
ClientSecrets clientSecret = new ClientSecrets();
clientSecret.ClientId = "xxx.apps.googleusercontent.com";
clientSecret.ClientSecret = "yyyyyy";
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
clientSecret,
new[] { YouTubeService.Scope.YoutubeUpload },
"user",
CancellationToken.None);
我无法确定的是如何在不同的youtube帐户之间切换。我有不止一个youtube帐户,并且希望在桌面应用程序中的不同场景中使用它们
当我最初使用注释掉的代码片段时,它使用json文件作为用户凭证——但这是静态信息。然后,我将代码更改为您在上面看到的内容,但我打算更改代码,以便为ClientSecret使用不同的值来选择相应的youtube帐户
在我第一次运行该应用程序时,它会提示我选择要使用的google/youtube帐户,并且工作正常,但我不知道如何在代码中切换到不同的帐户。我已经通读了谷歌api,但无法确定如何做到这一点。我尝试过不提供ClientSecret,但得到一个例外,没有提供ClientSecret,这很有意义。这有帮助吗@jwilleke-不,那是用于web项目的。