protected bool Login() { //check if already logged in if (!string.IsNullOrEmpty((service.RequestFactory as Google.GData.Client.GDataGAuthRequestFactory).GAuthToken)) { return(true); } // check if we can login if (!string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(login)) { // do login service.setUserCredentials(login, password); try { string token = service.QueryClientLoginToken(); service.SetAuthenticationToken(token); return(true); } catch (Exception ex) { throw new OnlineVideosException(ex.Message); } } return(false); }
public static void Initialize() { try { YouTubeService service = new YouTubeService("Manager"); service.setUserCredentials("*****@*****.**", "AI39si7k1PTGjYF"); service.QueryClientLoginToken(); yousettings = new YouTubeRequestSettings("You Manager", "AIzaSyAeo7byS85LCZUtrBodQ6E6OqlFlJROnMA"); yourequest = new YouTubeRequest(yousettings); } catch { } }
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"); } }