youtube api 无法上传到我的频道

问题描述 投票:0回答:0

我正在使用 C# (.net 7) 和 google api 包上传但无法上传到特定频道。好像忽略了

video.Snippet.ChannelId

video.Snippet.ChannelId = "UCfzaSOpwn0iY15Lmu3bLtkA";

每当我尝试以这种方式上传时,它都会上传到个人帐户(默认的 youtube 频道)

我也试过用

OnBehalfOfContentOwnerChannel
OnBehalfOfContentOwner

            var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");

            videosInsertRequest.OnBehalfOfContentOwnerChannel = "UCXXXXXXXXXX";
            videosInsertRequest.OnBehalfOfContentOwner = "{ChannelHandler*}";

我收到以下错误;

An error prevented the upload from completing.
The service youtube has thrown an exception.
HttpStatusCode is Forbidden.
Google.Apis.Requests.RequestError
The authenticated user cannot act on behalf of the specified Google account. [403]
Errors [
    Message[The authenticated user cannot act on behalf of the specified Google account.] Location[ - ] Reason[accountDelegationForbidden] Domain[youtube.common]
]

Google.GoogleApiException: The service youtube has thrown an exception. HttpStatusCode is Forbidden. The authenticated user cannot act on behalf of the specified Google account.
   at Google.Apis.Upload.ResumableUpload`1.InitiateSessionAsync(CancellationToken cancellationToken)
   at Google.Apis.Upload.ResumableUpload.UploadAsync(CancellationToken cancellationToken)

我很确定我错过了什么,但不确定是什么。我有类似的问题来下载我自己的字幕,但我假设这也会解决这个问题。

*频道处理程序是您在带有@的频道页面中看到的内容,例如https://www.youtube.com/@VOLEapp我假设它是VOLEapp

谢谢,

.net-core youtube-api youtube-data-api
© www.soinside.com 2019 - 2024. All rights reserved.