Youtube Upload: The remote server returned an error: (403) Forbidden

Last Reply on Apr 20, 2015 05:27 AM By Mudassar

Posted on Apr 20, 2015 12:37 AM

I am trying to upload video to youtube, directly from my application. But it is showing the following Error

"The remote server returned an error: (403) Forbidden."

Here is my code

 public static string UploadVideo(string FilePath, string Title, string Description)
    {
        YouTubeRequestSettings settings;
        YouTubeRequest request;
        string devkey = "AI39si5CQ_i4fT09NNSeBJMd2nAQuQGHN8EiqXzcjdfP2xfRSqZ7dufT0LSXlhD9ruj6bzS_9Vqo0ahhtndhKFIUI5aj2FI0sQ";
        string username = "shaiwal2shaiwal@gmail.com";
        string password = "mygmailpassword";
        settings = new YouTubeRequestSettings("Video", devkey, username, password) { Timeout = -1 };
        request = new YouTubeRequest(settings);

        Video newVideo = new Video();

        newVideo.Title = Title;
        newVideo.Description = Description;
        newVideo.Private = true;
        newVideo.YouTubeEntry.Private = false;
        newVideo.YouTubeEntry.MediaSource = new MediaFileSource(FilePath, "video/mp4");
        Video createdVideo = request.Upload(newVideo);

        return createdVideo.VideoId;
    }