title: Adding comments with the Youtube API randomly failing in .NET
body: <p>I am using a C# .NET 2.0 winform in 2010, I have added the ability for a user to log in and post comments. I copied the .NET developer guide in how to post comments but I am getting random but frequent exceptions when trying to post comments. At first I thought it might be because there is some issue with using a google e-mail instead of the youtube log in name, to get around this when a user succesfully logs in I request the profile, get the user name and create a new youtube settings class and give the appropriate credentials with the users profile name. This however hasn't resolved the issue, the comments still work sporadically. Here is the code that basically handles logging in.</p>
  
  <pre><code>       youtubeService.setUserCredentials(userBox.Text, passwordBox.Text);
  
          try
          {
              String strAuth = youtubeService.QueryClientLoginToken();
          }
          catch (Exception ex)
          {
          }         
  </code></pre>
  
  <p>The above code is in a seperate form, the form that hosts the youtube video basically looks to see if this process has been completed and grabs the username, password used to log in and sets the new settings:</p>
  
  <pre><code>                m_LoggedInSettings = new YouTubeRequestSettings(myappname, mydevkey, username, password);
                  m_LoggedInRequest = new YouTubeRequest(m_LoggedInSettings); 
  </code></pre>
  
  <p>This then used to add a comment:</p>
  
  <pre><code>                Comment userComment = new Comment();
                  userComment.Content = commentText;
                  m_LoggedInRequest.AddComment(youtubevideo, userComment);   
  </code></pre>
  
  <p>When it fails I get the following:</p>
  
  <p>{"Execution of request failed: <a href="https://gdata.youtube.com/feeds/api/videos/t-8K8Hj8bxE/comments" rel="noreferrer">https://gdata.youtube.com/feeds/api/videos/t-8K8Hj8bxE/comments</a>"}</p>
  
  <p>With the following info:</p>
  
  <p>{"The remote server returned an error: (403) Forbidden."}</p>
  
  <p>Status code:</p>
  
  <p>System.Net.HttpStatusCode.Forbidden</p>
  
  <p>Status description:</p>
  
  <p>Forbidden</p>
  
  <p>A few things come to mind, I do not have a proper log out that sends anything to youtube implimented at the minute (is this needed?), so it may be that I've logged in multiple times and that is somehow flagging on youtubes side? It could also be that I am essentially creating new settings and request objects that weren't used to get the video/comments and maybe the video taken from the normal settings file (with no log in) is giving problems or something like that? To be honest, I haven't got a clue what is wrong and any help would be greatly appriecated. </p>