private void loginDone_Click(object sender, EventArgs e) { String key = @"AI39si5BLf_EKytNzPVPtepg-yNDLPSxKOP9ZCBaDTErR5nWmFMy36d8jnKOfwU3PN0c61au0l6b68k9lk7GRluBKh7lvlNRzA"; //My personal API key. YouTubeService service = new YouTubeService("YouTube Synchronizer"); service.setUserCredentials(textLogin.Text, textPassword.Text); //textbox1 contains username and maskedTextBox1 contains password try { service.QueryClientLoginToken(); this.Hide(); } catch (InvalidCredentialsException j) { loginTxt_lbl.Visible = true; } YouTubeRequestSettings settings = new YouTubeRequestSettings("Deprecated", key, textLogin.Text, textPassword.Text); Youtube_Uploader.Properties.Settings.Default.UsernameYT = textLogin.Text; Youtube_Uploader.Properties.Settings.Default.PasswordYT = textPassword.Text; Youtube_Uploader.Properties.Settings.Default.Save(); MainForm.request = new YouTubeRequest(settings); }
private void button1_Click(object sender, EventArgs e) { login = "******"; password = "******"; if (!logged) { YouTubeService service = new YouTubeService("Manager"); service.setUserCredentials(login, password); try { service.QueryClientLoginToken(); } catch (System.Net.WebException ex) { MessageBox.Show(ex.Message); } yousettings = new YouTubeRequestSettings("YTPlayer","AI39si40b25zgBg_U7eheiSnNeb2UMF-3x35HLBYxQDXJEzYOrA8GSQ1vKikFIRSMGOTjBdFvUx4QPz3q72gUkUqOmg9JBx3bQ", login, password); yourequest = new YouTubeRequest(yousettings); logged = true; } YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri); query.OrderBy = "viewCount"; query.Query = textBox1.Text; videofeed = yourequest.Get<Video>(query); videofeedcount = videofeed.TotalResults; totalpages = videofeedcount / 25; if (videofeedcount % 25 != 0) totalpages = totalpages + 1; listView1.Items.Clear(); videoIDs.Clear(); foreach (Video entry in videofeed.Entries) { listView1.Items.Add(entry.Title); videoIDs.Add(entry.VideoId); } }
private void btnLogin_Click(object sender, EventArgs e) { var service = new YouTubeService("iSpy", MainForm.Conf.YouTubeKey); service.setUserCredentials(txtYouTubeUsername.Text, txtYouTubePassword.Text); string token = ""; try { token = service.QueryClientLoginToken(); } catch(InvalidCredentialsException) { MessageBox.Show(this, "Login Failed"); } catch(Exception ex) { MessageBox.Show(ex.Message); } if (token != "") MessageBox.Show(this, "Login OK"); }
private void Login() { ytService = new YouTubeService(APP_NAME, DEV_KEY); ytService.setUserCredentials(USERNAME, PASSWORD); ytRequest = new YouTubeRequest(new YouTubeRequestSettings(APP_NAME,DEV_KEY)); try { LOGIN_TOKEN = ytService.QueryClientLoginToken(); isLoggedIn = LOGIN_TOKEN.Length > 0; if (isLoggedIn) { ProfileEntry profile = (ProfileEntry)ytService.Get(@"https://gdata.youtube.com/feeds/api/users/default"); if (profile == null) return; userProfile.NICKNAME = profile.Firstname + " " + profile.Lastname; userProfile.AGE = "Age: " + profile.Age; userProfile.HOBBIES = "Hobbies: " + profile.Hobbies; userProfile.ID = "ID:" + profile.Id.ToString(); userProfile.HOMETOWN = "Hometown: " + profile.Hometown; userProfile.COMPANY = profile.Company; userProfile.LOCATION = profile.Location; userProfile.RELATIONSHIP = profile.Relationship; userProfile.SCHOOL = profile.School; Statistics statistics = profile.Statistics; if (statistics != null) { userProfile.SUBSCRIBE_COUNT = statistics.SubscriberCount; userProfile.WATCH_COUNT = statistics.WatchCount; userProfile.VIEW_COUNT = statistics.ViewCount; userProfile.FAVORITE_COUNT = statistics.FavoriteCount; } var thumbnail = (from e in profile.ExtensionElements where e.XmlName == "thumbnail" select (XmlExtension)e).SingleOrDefault(); string thumbnailUrl = ""; if (thumbnail != null) { thumbnailUrl = thumbnail.Node.Attributes["url"].Value; } userProfile.AVATAR = thumbnailUrl; } } catch { isLoggedIn = false; } }
private static void Connect(string username, string password) { if (string.IsNullOrEmpty (username) || string.IsNullOrEmpty (password)) { Log<Youtube>.Error (MissingCredentialsMessage); return; } try { service = new YouTubeService (appName, clientID, developerKey); service.setUserCredentials (username, password); ServicePointManager.CertificatePolicy = new CertHandler (); } catch (Exception e) { Log<Youtube>.Error (ConnectionErrorMessage); Log<Youtube>.Error (e.Message); } }
public static bool TryConnect(string username, string password) { try { service = new YouTubeService (appName, clientID, developerKey); service.setUserCredentials (username, password); Connect (username, password); } catch (Exception) { Log<Youtube>.Error (ConnectionErrorMessage); return false; } return true; }
private void button3_Click(object sender, RoutedEventArgs e) { var service = new YouTubeService("YouTube Synchronizer"); service.setUserCredentials(txtLogin.Text, passwordBox1.Password); try { service.QueryClientLoginToken(); lblBadCredentials.Visibility = Visibility.Hidden; lblLoginSuccess.Visibility = Visibility.Visible; txtLogin.IsEnabled = false; passwordBox1.IsEnabled = false; //Use a validation object here to set the login as good? } catch { lblBadCredentials.Visibility = Visibility.Visible; lblLoginSuccess.Visibility = Visibility.Hidden; } }