private void service_oauth() { // MessageBox.Show(RefreshKey_saved); if (RefreshKey_saved != "") { bool result = getAccessToken("aa"); if (result == true) { myTabControl.SelectedIndex = 0; // set focus to AutoCompleteBox AutoCompleteBox.Focusable = true; Keyboard.Focus(AutoCompleteBox); return; } else { iniParser parser = new iniParser(); String appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); parser.IniParser(iniPath); parser.AddSetting("Setup", "refreshkey", ""); parser.SaveSettings(); RefreshKey_saved = ""; if (initialState == true) { // no switch screen myTabControl.SelectedIndex = 0; return; } myTabControl.SelectedIndex = 1; // access token expire } // set focus to AutoCompleteBox AutoCompleteBox.Focusable = true; Keyboard.Focus(AutoCompleteBox); } //------- consumer = new NativeApplicationClient(server, clientID, clientSecret); Uri userAuthorizationUri = consumer.RequestUserAuthorization(scope2); //label_msg.DataContext = GoogleScope.ImapAndSmtp.Name; //GoogleScope.EmailAddressScope.Name string address = "https://accounts.google.com/o/oauth2/auth" + "?client_id=" + clientID + "&response_type=code" + "&access_type=offline" + "&scope=" + GoogleScope.ContactsScope.Name + //GoogleScope.ImapAndSmtp.Name + "&redirect_uri=" + "urn:ietf:wg:oauth:2.0:oob"; wb1.Navigate(new Uri(address, UriKind.Absolute)); wb1.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(wb1_LoadCompleted); }
private void service_oauth() { if (RefreshKey_saved != "") { bool result =getAccessToken("aa"); if (result == true) { myTabControl.SelectedIndex=0; // set focus to AutoCompleteBox AutoCompleteBox.Focusable = true; Keyboard.Focus(AutoCompleteBox); return; } else { iniParser parser = new iniParser(); String appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); parser.IniParser(iniPath); parser.AddSetting("Setup", "refreshkey", ""); parser.SaveSettings(); RefreshKey_saved = ""; myTabControl.SelectedIndex = 1; // access token expire } // set focus to AutoCompleteBox AutoCompleteBox.Focusable = true; Keyboard.Focus(AutoCompleteBox); // change code immediately //string _accesstoken= consumer.GetScopedAccessToken(RefreshKey_saved,_set1); //consumer.RefreshAuthorization(grantedAccess, TimeSpan.FromMinutes(20)); //accessToken = grantedAccess.AccessToken; } //------- consumer = new NativeApplicationClient(server, clientID, clientSecret); Uri userAuthorizationUri = consumer.RequestUserAuthorization(scope2); //label_msg.DataContext = GoogleScope.ImapAndSmtp.Name; //GoogleScope.EmailAddressScope.Name string address = "https://accounts.google.com/o/oauth2/auth" + "?client_id=" + clientID + "&response_type=code" + "&access_type=offline" + "&scope=" + GoogleScope.ContactsScope.Name + //GoogleScope.ImapAndSmtp.Name + "&redirect_uri=" + "urn:ietf:wg:oauth:2.0:oob"; wb1.Navigate(new Uri(address, UriKind.Absolute)); wb1.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(wb1_LoadCompleted); }