0

I am using following code to upload a video to YouTube. It always gives following error.

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

My Code is

        YouTubeRequestSettings settings;
        YouTubeRequest request;
        string devkey = YouTubeDeveloperKey;
        string username = YoutubeUserName;
        string password = YoutubePassword;
        settings = new YouTubeRequestSettings("VideoEditor", 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/flv");
        Video createdVideo = request.Upload(newVideo);

Please do you have any idea about this error

Arin Ghazarian
  • 5,105
  • 3
  • 23
  • 21
las
  • 67
  • 1
  • 3
  • 13

2 Answers2

0

As per the Youtube API V2 documentation, error 403 is an authorization error.

Most probably the username and password might be wrong.

My guess: Did you enable two step authentication on your Google account ? If so, you must use an application-specific password.

Raju Mandapati
  • 691
  • 6
  • 22
  • No, I didn't enable two step authentication , Username and Password correct, I can log into YouTube using the browser – las Jan 08 '14 at 10:21
  • Try to set a breakpoint at `request = new YouTubeRequest(settings);` and hover over `settings` to see its value and make sure that the username and password are what you are expecting them to be. – Raju Mandapati Jan 08 '14 at 13:10
  • And please look into [this question](http://stackoverflow.com/questions/10759032/how-to-use-the-youtube-api-login-procedure-using-c) already asked on SO and confirm to yourself that you are sending the right credentials. And also follow the answer in [that question](http://stackoverflow.com/questions/10759032/how-to-use-the-youtube-api-login-procedure-using-c). – Raju Mandapati Jan 08 '14 at 13:13
0

Try to go to your youtube application via https://console.developers.google.com then select your application go to APIs and auth -> APIs. It will display a list of multiple available APIs, click on Youtube Data API, and then click "enable". This will enable this API to be used by your app and most likely will solve your issue.

Alex P
  • 39
  • 5