1

我使用Youtube Data API V3使用Oauth 2.0身份驗證將視頻上傳到我的YouTube帳戶。將視頻自動上傳到我的帳戶,使用YouTube數據API V3無需用戶同意

UserCredential credential; 
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read)) 
{ 
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
    GoogleClientSecrets.Load(stream).Secrets, 
    new[] { YouTubeService.Scope.YoutubeUpload }, 
    "user", 
    CancellationToken.None 
); 
} 

var youtubeService = new YouTubeService(new BaseClientService.Initializer() 
{ 
HttpClientInitializer = credential, 
ApplicationName = Assembly.GetExecutingAssembly().GetName().Name 
}); 

在驗證過程中這顯示了登錄和同意畫面獲取授權如圖

Oauth_UserConsent

我需要克服以上,使未經用戶同意我想在YouTube數據API V3使用OAuth 2.0進行驗證,並將視頻上傳到我的帳戶。

因此,我發現'服務帳戶'可以用於這種場景,但又發現服務帳戶不適用於Youtube數據API,因爲服務帳戶需要關聯的YouTube頻道,並且您不能關聯新的或現有頻道與服務帳戶的鏈接https://developers.google.com/youtube/v3/guides/moving_to_oauth 是否有dotnet的任何替代方式來跳過用戶同意,並得到編程驗證,做編程方式上傳視頻到我的帳戶

回答

相關問題