Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Upload to my own Youtube channel without user login everytime

$
0
0

I followed the documentation and created a C# client to upload videos to my channel. I only upload once a week, and every time I execute this function, I have to log in and give consent to the application.

My questions: Is there a way to upload to my own channel without user intervention. Ideally I want to automate this process to happen without involving a human.

Is there a way to get tokens silently, such as by using client credentials?

public async Task Upload(string filePath, VidData vidData){    Notify("Preparing to upload to youtube, getting token...");    UserCredential credential;    using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))    {        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        );    }    var youtubeService = new YouTubeService(new BaseClientService.Initializer()    {        HttpClientInitializer = credential,        ApplicationName = Assembly.GetExecutingAssembly().GetName().Name    });    var video = new Video();    video.Snippet = new VideoSnippet();    video.Snippet.Title = vidData.Title;    video.Snippet.Description = vidData.Description;    video.Snippet.Tags = vidData.Tags;    video.Snippet.CategoryId = "22"; // See     video.Status = new VideoStatus();    video.Status.PrivacyStatus = "public"; // or "private" or "public"    Notify("Token recived, Uploading to youtube...");    using (var fileStream = new FileStream(filePath, FileMode.Open))    {        var videosInsertRequest = youtubeService.Videos.Insert(video, "snippet,status", fileStream, "video/*");        videosInsertRequest.ProgressChanged += videosInsertRequest_ProgressChanged;        videosInsertRequest.ResponseReceived += videosInsertRequest_ResponseReceived;        await videosInsertRequest.UploadAsync();    }

Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>