authenticationyoutube-apiyoutube.net-api

Captcha required youtube api C#


Every time I make a request for getting a video to youtube API I make something like that:

public Video GetVideo(string videoId)
{
    YouTubeRequest request = new YouTubeRequest(settings);

    Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos/" + videoId);

    return request.Retrieve<Video>(videoEntryUrl);
}

Sometimes I get an exception saying "Captcha required". I was wondering if building the YoutubeRequest is asking for an authentication token for every call to GetVideo and because of that I'm getting this exception. Is it possible? How can I avoid this exception? And I'm not talking about handling it with a try-catch.

Thanks!!


Solution

  • Yes; there are ways of reusing a ClientLogin token. Please see scenario 4 in this blog post, and take a look at the "Recalling an auth token" section of this document.

    Better yet, I'd recommend making the move to OAuth 2 instead of ClientLogin, as mentioned in that blog post.