Tuesday, April 24, 2012

[YouTube-API] Uploading video to youtube using client authentication

Hi

I am trying to upload video to youtube using direct upload and
clientLogin authentication but I am getting "NoLinkedYouTubeAccount"
error

I can read the feeds using api but uploading seems to be a problem. I
can also log into the youtube using my username and password
my code is displayed below

Video newVideo = new Video();
YouTubeService service = new YouTubeService("admin-
testimonial-videos");
service.setUserCredentials("user_name", "password");

try
{
token = service.QueryClientLoginToken();
}
catch (System.Net.WebException e) { throw e; }


var yousettings = new
YouTubeRequestSettings("app_name", "app_key","username","password");
var yourequest = new YouTubeRequest(yousettings);


filePath = "path" + videoFile.FileName;

newVideo.Title = video.Title;
newVideo.Tags.Add(new MediaCategory(video.Category,
YouTubeNameTable.CategorySchema));
newVideo.Keywords = video.Keywords;
newVideo.Description = video.Description;
newVideo.YouTubeEntry.Private = !video.VisibleToAll;
newVideo.Tags.Add(new MediaCategory("mydevtag,
anotherdevtag", YouTubeNameTable.DeveloperTagSchema));

//newVideo.YouTubeEntry.Location = new GeoRssWhere(37,
-122);
newVideo.YouTubeEntry.setYouTubeExtension("location",
video.VideoLocation);
newVideo.YouTubeEntry.MediaSource = new
MediaFileSource(filePath, "video/quicktime");

//Video createdVideo = request.Upload(newVideo);
try
{
Video createdVideo = yourequest.Upload(newVideo);
}
catch (GDataRequestException e)
{
throw e;
}

Any help would be appreciated

Thanks

Nouman Shams

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment