private void googleDriveToolStripMenuItem_Click(object sender, EventArgs e) { if (_Gmail == null || _Gpass == null) { ToErrorLog("Отсутствие данных", "Авторизация Google", "Ключ не содержал данных!"); return; } parameters.ClientId = CLIENT_ID; parameters.ClientSecret = CLIENT_SECRET; parameters.RedirectUri = REDIRECT_URI; //////////////////////////////////////////////////////////////////////////// // STEP 3: Get the Authorization URL //////////////////////////////////////////////////////////////////////////// // Set the scope for this particular service. parameters.Scope = SCOPE; // Get the authorization url. The user of your application must visit // this url in order to authorize with Google. If you are building a // browser-based application, you can redirect the user to the authorization // url. string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters); //System.Diagnostics.Process.Start(authorizationUrl); Authentication auth = new Authentication(); auth.URL = authorizationUrl; auth.Gpass = _Gpass; auth.Gmail = _Gmail; auth.ShowDialog(); if (auth.Key != null) { parameters.AccessCode = auth.Key; OAuthUtil.GetAccessToken(parameters); string accessToken = parameters.AccessToken; GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", parameters); service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; GooglePicture.Image = Properties.Resources.googleDrive as Bitmap; GoogleToolTip.SetToolTip(this.GooglePicture, "Доступ к Google Disk\nразрешен."); } else { MessageBox.Show("Вход не выполнен", "Google Service Access", MessageBoxButtons.OK, MessageBoxIcon.Error); } ToLog("Авторизация Google", string.Format(auth.Info)); auth.Close(); }
/// <summary> /// События при загрузке формы /// </summary> private void Form1_Load(object sender, EventArgs e) { /*const string userRoot = "HKEY_LOCAL_MACHINE"; * const string subkey = "SNMP_Worker"; * const string keyName = userRoot + "\\SOFTWARE\\" + subkey; * DirectoryPath = (string)Registry.GetValue(keyName,"PrgPath",null); * DirectoryPath = DirectoryPath.Remove(DirectoryPath.LastIndexOf("\\"));*/ // MessageBox.Show(DirectoryPath); //SetPathFromRegystry(); myAccessConn = new OleDbConnection(strAccessConn); myAccessConn.Open(); numbers = new Stack <int>(); numbers.Push(1); LoadDll(); GoogleToolTip.SetToolTip(this.GooglePicture, "Доступ к Google Disk\nне разрешен."); DBtoolTip.SetToolTip(this.DBPicture, "Ведется протоколирование."); }