I'm trying to use YouTube API to upload videos from browser. I read Google API documentation and wrote this piece of code:
public static YouTubeRequest GetRequest()
{
var request = HttpContext.Current.Session["YTRequest"] as YouTubeRequest;
if (request == null)
{
var settings = new YouTubeRequestSettings("WebApp", "NA", ConfigurationManager.AppSettings["YouTubeAPIDeveloperKey"]);
settings.AutoPaging = true;
request = new YouTubeRequest(settings);
HttpContext.Current.Session["YTRequest"] = request;
}
return request;
}
var youTubeRequest = GetRequest();
var newVideo = new Video { Title = "Title", Description = "Description" };
newVideo.YouTubeEntry.Private = false;
var token = youTubeRequest.CreateFormUploadToken(newVideo);
var postUrl = token.Url;
var tokenValue = token.Token;
But I always receive this error message: The remote server returned an error: (401) Unauthorized.
on this line:
var token = youTubeRequest.CreateFormUploadToken(newVideo);
I think my issue is not related to Developer API key. It is correctly grabbed from API Dashboard.
Any idea?