I am creating an ASP.NET C # application that uploads a video to a YouTube channel. * I have already read (as far as possible) the documentation on
YouTube API Documentation
I was able to successfully implement two examples of uploading videos to a YouTube channel using the provided sample code.
For example, using the direct method (only important code):
<!-- eja: import the google libraries --> <%@ Import Namespace="Google.GData.Client" %> <%@ Import Namespace="Google.GData.Extensions" %> <%@ Import Namespace="Google.GData.YouTube" %> <%@ Import Namespace="System.Net" %> <!-- some more code --> <% // specify where to go to once authenticated Uri targetUri = new Uri(Request.Url, "VideoManager.aspx"); // hide the link to authenticate for now. GotoAuthSubLink.Visible = false; // GotoAuthSubLink.Visible = true; // look for a session var storing the auth token. if it not empty if (Session["token"] != null) { // go to the VideoManager link Response.Redirect(targetUri.ToString()); } else if (Request.QueryString["token"] != null) { // if we have the auth key in the URL, grab it from there instead String token = Request.QueryString["token"]; // set the session equal to AuthSubUtil calling the exchangeForSessionToken method // returns the token and convert it to a string Session["token"] = AuthSubUtil.exchangeForSessionToken(token, null).ToString(); Response.Redirect(targetUri.ToString(), true); } else { //no auth token, display the link and create the token by loading the google // auth page String authLink = AuthSubUtil.getRequestUrl(Request.Url.ToString(), "http://gdata.youtube.com", false, true); GotoAuthSubLink.Text = "Login to your Google Account"; GotoAuthSubLink.Visible = true; GotoAuthSubLink.NavigateUrl = AuthSubUtil.getRequestUrl(Request.Url.ToString(),"http://gdata.youtube.com",false,true); } <asp:HyperLink ID="GotoAuthSubLink" runat="server"/>
This page is one ... it loads the Google authentication screen. (see the link to the attached image, it is safe, I just set up a new account here in stackOverflow and cannot upload images yet).

Then it leads to the page with the loading mechanism ... The download work It doesnβt bother me, but here is the FYI code fragment.
// create an instance ot the YouTubeService class. passing the application name and my DEV KEY YouTubeService service = new YouTubeService(authFactory.ApplicationName, **API_KEY**); // retrieve the current session token as a string if any authFactory.Token = HttpContext.Current.Session["token"] as string; // incorporate the information into our service service.RequestFactory = authFactory; try { // a YouTubeEntry object is single entity within a videoFeed object. It generally contains info // about the video. when uploading, we will assign the values that we received to the feed. YouTubeEntry entry = new YouTubeEntry(); // aggregate all the initial descriptor information entry.Media = new Google.GData.YouTube.MediaGroup(); entry.Media.Description = new MediaDescription(this.Description.Text); entry.Media.Title = new MediaTitle(this.Title.Text); entry.Media.Keywords = new MediaKeywords(this.Keyword.Text); // process entry.Media.Categories to assign the category MediaCategory category = new MediaCategory(this.Category.SelectedValue); category.Attributes["scheme"] = YouTubeService.DefaultCategory; entry.Media.Categories.Add(category); // prepare the token used for uploading FormUploadToken token = service.FormUpload(entry); HttpContext.Current.Session["form_upload_url"] = token.Url; HttpContext.Current.Session["form_upload_token"] = token.Token; // construct the URL string page = "http://" + Request.ServerVariables["SERVER_NAME"]; if (Request.ServerVariables["SERVER_PORT"] != "80") { page += ":" + Request.ServerVariables["SERVER_PORT"]; } page += Request.ServerVariables["URL"]; HttpContext.Current.Session["form_upload_redirect"] = page; Response.Redirect("UploadVideo.aspx");
The UploadVideo.aspx page is the actual upload form and it works, so it doesn't bother me.
An alternative method is not a recommended method because it is synchronous in nature, but it avoids this login screen because it allows us to pass credentials for authentication (it works as a web application) ... again, the main code below.
<% GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory(ServiceNames.YouTube, "TesterApp"); // Response.Write("serviceNames.youtube=" + ServiceNames.YouTube + "<br />"); YouTubeRequestSettings s = new YouTubeRequestSettings(authFactory.ApplicationName, **your API KEY**,**Your email account as a username**,**your password**); YouTubeRequest request = new YouTubeRequest(s); Video newVideo = new Video(); newVideo.Title = "test at 4:40"; newVideo.Tags.Add(new MediaCategory("Games", YouTubeNameTable.CategorySchema)); newVideo.Keywords = "cars, funny"; newVideo.Description = "My description"; newVideo.YouTubeEntry.Private = false; // newVideo.Tags.Add(new MediaCategory("mydevtag, anotherdevtag", YouTubeNameTable.DeveloperTagSchema)); // newVideo.YouTubeEntry.Location = new GeoRssWhere(37, -122); // alternatively, you could just specify a descriptive string newVideo.YouTubeEntry.setYouTubeExtension("location", "Somewhere,Someplace"); newVideo.YouTubeEntry.MediaSource = new MediaFileSource("C:\\IMG_1672.MOV", "video/quicktime"); Video createdVideo = request.Upload(newVideo); Response.Write("This will print out once the file is uploaded...indicates that the code is <i>synchronous</i>. The cursor spins around until done. go get a coffee then check the YouTube Channel"); %>
So basically, the question I ask is the method that will upload the video to the YouTube channel in ASP.NET C # code a) for the web application b) that I can pass the credentials through the code before c) workaround Google authentication screen shown above, and d) without using OAuth and openID and certificate, etc.?
The application is intended only for a short campaign (November only), and I am happy to use the outdated authSubUtil and the developer key, and you do not need to worry about oAuth 2.x or open ID (since authsubutil will refuse 2015 anyway).
Any help is appreciated.
thanks
Edward