public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user) { bool validationResult = Task.Run(() => ValidateAsync(account.Token)).Result; if (!validationResult) { return(new LoginResult { Status = false, Message = "Access is denied" }); } var gUser = new GoogleUserInfo { Email = account.Email, Name = account.Name }; var result = GoogleSignIn.SignIn(account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture); if (result.Status) { if (!Registrations.HasAccount(account.Email)) { string template = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html"; var welcomeEmail = new WelcomeEmail(gUser, template, ProviderName); await welcomeEmail.SendAsync(); } } return(result); }
public void InsertTestData() { var repo = new UStoreRepository(); var droidrrcAccount = new GoogleAccount(); droidrrcAccount.DisplayName = "DroidRRc"; var acc = repo.GetAll <GoogleAccount>(a => a.DisplayName == droidrrcAccount.DisplayName); if (acc.Count() == 0) { repo.Store(droidrrcAccount); } var rino13Acc = new GoogleAccount { DisplayName = "rinorc13" }; acc = repo.GetAll <GoogleAccount>(a => a.DisplayName == rino13Acc.DisplayName); if (acc.Count() == 0) { repo.Store(rino13Acc); } }
private async void GLoginBrowser_Navigated(object sender, NavigationEventArgs e) { ShowProgressBar(true); string token = e.Uri.Query; if (e.Uri.Query.Contains("xsrf")) { string source = GLoginBrowser.SaveToString(); int start = source.IndexOf("<title>") + 20; int end = source.IndexOf("</title>"); string authCode = source.Substring(start, end - start); bool completed = await GoogleAccount.Authorize(authCode); while (!completed) { ; } ShowProgressBar(false); NavigationService.Navigate(new Uri("/Views/Birthdays.xaml", UriKind.RelativeOrAbsolute)); } }
public bool Authorize(GoogleAccount account) { DictionaryDataStore dataStore = new DictionaryDataStore(); if (account != null) { account.LoadDataStore(dataStore: ref dataStore); } try { UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync( clientSecrets: GoogleSecrets.ToClientSecrets(Secrets), scopes: GoogleScopes.ToStrings(Scopes), user: "******", taskCancellationToken: CancellationToken.None, dataStore: dataStore ).Result; Accounts.Add(GoogleAccount.SaveAccount(broker: this, credential: credential, dataStore: dataStore)); return(true); } catch (TokenResponseException ex) { if (ex.Message.Contains("invalid_grant")) { return(account.Reauthenticate()); } else { Log.Error(ex); } return(false); } }
public void unsubscribeAccount(Dictionary <String, YouTubeChannel> channels) { Console.WriteLine("Enter your google account username: "******"Enter youtube channel to unsubscribe: "); String channelName = Console.ReadLine(); try { GoogleAccount googleAccount = this.googleAccounts[username]; try { YouTubeChannel channel = channels[channelName]; googleAccount.unsubscribe(channel); } catch (KeyNotFoundException) { Console.WriteLine("Youtube channel name you want to unsubscribe does not exist!"); } } catch (KeyNotFoundException) { Console.WriteLine("Your google account name is incorrect!"); } }
public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user) { bool validationResult = Task.Run(() => this.ValidateAsync(account.Token)).GetAwaiter().GetResult(); if (!validationResult) { return(new LoginResult { Status = false, Message = Resources.AccessIsDenied }); } var gUser = new GoogleUserInfo { Email = account.Email, Name = account.Name }; var result = await GoogleSignIn.SignInAsync(this.Tenant, account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture).ConfigureAwait(false); if (result.Status) { if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false)) { string template = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html"; var welcomeEmail = new WelcomeEmail(gUser, template, ProviderName); await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false); } } return(result); }
//------------------------------------------------------------------- #region Methods for manipulation the inbox gmail page /// <summary>Quit from current account</summary> public void QuitFromAccount() { GoogleAccount.Click(); GoogleAccountPopUp accountPopUp = new GoogleAccountPopUp(this.driver); accountPopUp.SignOutFromAccount(); }
private async void AddGoogleAccountDetailsToApplication(string accountName) { var account = new GoogleAccount { Name = accountName }; Settings.GoogleAccounts.Add(account.DeepClone()); LastSavedSettings.GoogleAccounts.Add(account); await SettingsSerializationService.SerializeSettingsAsync(LastSavedSettings); }
/// <summary> /// Creates the google account. /// </summary> /// <param name="userProfileId">The user profile identifier.</param> /// <param name="googleAccountId">The google account identifier.</param> /// <returns></returns> public async Task <bool> CreateGoogleAccount(Guid userProfileId, string googleAccountId) { var googleAccount = new GoogleAccount { UserProfileId = userProfileId, GoogleAccountId = googleAccountId }; _googleAccountRepository.Insert(googleAccount); await _unitOfWork.CommitAsync(); return(true); }
public async Task <ActionResult> GoogleSignInAsync(GoogleAccount account) { try { var oauth = new GoogleAuthentication(this.Tenant); var result = await oauth.AuthenticateAsync(account, this.RemoteUser).ConfigureAwait(false); return(await this.OnAuthenticatedAsync(result).ConfigureAwait(true)); } catch (NpgsqlException) { return(this.AccessDenied()); } }
public void TestMethod1() { var account = new GoogleAccount(); account.DisplayName = "droidrrc"; var repo = new UStoreRepository(); //var result = repo.Store(account); //var result3 = repo.Store(account); //var result2 = repo.Store(result); var re = repo.GetAll <GoogleAccount>(); }
public async Task <ActionResult> GoogleSignInAsync(GoogleAccount account) { try { var oauth = new GoogleAuthentication(); var result = await oauth.AuthenticateAsync(account, this.RemoteUser); return(OnAuthenticated(result)); } catch (NpgsqlException) { return(this.AccessDenied()); } }
public async Task <ActionResult> GoogleSignInAsync(GoogleAccount account) { try { GoogleAuthentication oauth = new GoogleAuthentication(); LoginResult result = await oauth.AuthenticateAsync(account, this.RemoteUser); return(OnAuthenticated(result)); } catch (NpgsqlException) { return(Json("Access is denied.")); } }
public void viewGoogleAccountMails() { Console.WriteLine("Enter google account username: "******"Google account name does not exist!"); } }
public void sendMail() { Console.Write("Enter your google account username: "******"Enter reciever google account username: "******"Google account names are invalid!"); } }
private GoogleAccount GetGoogleAccount(CalendarSyncProfile syncProfile) { GoogleAccount googleAccount = null; if (syncProfile.GoogleAccount != null) { if (GoogleAccounts.Any()) { googleAccount = GoogleAccounts.FirstOrDefault( account => account.Name == syncProfile.GoogleAccount.Name); } } if (googleAccount != null) { googleAccount.GoogleCalendar = syncProfile.GoogleAccount.GoogleCalendar; } return(googleAccount); }
private async void AddGoogleAccountDetailsToApplication(string accountName) { var account = new GoogleAccount { Name = accountName }; if (GoogleAccounts == null) { GoogleAccounts = new ObservableCollection <GoogleAccount>(); } GoogleAccounts.Add(account); SelectedProfile.SelectedGoogleAccount = account; SelectedProfile.GoogleCalendars = null; SelectedProfile.GetGoogleCalendar(); Settings.GoogleAccounts = GoogleAccounts; await SettingsSerializationService.SerializeSettingsAsync(Settings); }
private void Awake() { try { Instance = this; InitializeGooglePlayGamesService(); _waitingForAuth = true; linkGoogle.gameObject.SetActive(true); } catch { linkGoogle.gameObject.SetActive(false); } if (Social.localUser.authenticated) { _waitingForAuth = false; unlinkGoogle.gameObject.SetActive(true); showLeaderboard.gameObject.SetActive(true); showAchievement.gameObject.SetActive(true); linkGoogle.gameObject.SetActive(false); } }
internal void Initialize(GoogleAccount googleAccount) { Name = SyncProfile.Name; IsSyncEnabled = SyncProfile.IsSyncEnabled; IsDefault = SyncProfile.IsDefault; SyncRangeTypes = new List <SyncRangeTypeEnum> { SyncRangeTypeEnum.SyncEntireCalendar, SyncRangeTypeEnum.SyncFixedDateRange, SyncRangeTypeEnum.SyncRangeInDays }; CalendarSyncModes = new List <CalendarSyncDirectionEnum> { CalendarSyncDirectionEnum.OutlookGoogleOneWay, CalendarSyncDirectionEnum.OutlookGoogleOneWayToSource, CalendarSyncDirectionEnum.OutlookGoogleTwoWay }; SyncFrequencies = new List <string> { "Interval", "Daily", "Weekly" }; SyncFrequency = "Interval"; Categories = CategoryHelper.GetCategories(); SelectedSyncRangeType = SyncProfile.SyncSettings.SyncRangeType; DaysInPast = SyncProfile.SyncSettings.DaysInPast; DaysInFuture = SyncProfile.SyncSettings.DaysInFuture; StartDate = SyncProfile.SyncSettings.StartDate; EndDate = SyncProfile.SyncSettings.EndDate; AddAttendees = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.Attendees); if (AddAttendees) { AddAttendeesToDescription = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.AttendeesToDescription); } AddDescription = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.Description); AddReminders = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.Reminders); AddAttachments = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.Attachments); AddAsAppointments = SyncProfile.CalendarEntryOptions.HasFlag(CalendarEntryOptionsEnum.AsAppointments); IsDefaultProfile = SyncProfile.OutlookSettings.OutlookOptions.HasFlag(OutlookOptionsEnum.DefaultProfile) ? OutlookOptionsEnum.DefaultProfile : OutlookOptionsEnum.AlternateProfile; IsDefaultMailBox = SyncProfile.OutlookSettings.OutlookOptions.HasFlag(OutlookOptionsEnum.DefaultCalendar) ? OutlookOptionsEnum.DefaultCalendar : OutlookOptionsEnum.AlternateCalendar; IsExchangeWebServices = SyncProfile.OutlookSettings.OutlookOptions.HasFlag(OutlookOptionsEnum.ExchangeWebServices); SelectedOutlookProfileName = SyncProfile.OutlookSettings.OutlookProfileName; SelectedCalendarSyncDirection = SyncProfile.SyncSettings.CalendarSyncDirection; MasterCalendarServiceType = SyncProfile.SyncSettings.MasterCalendar; DisableDelete = SyncProfile.SyncSettings.DisableDelete; ConfirmOnDelete = SyncProfile.SyncSettings.ConfirmOnDelete; KeepLastModifiedCopy = SyncProfile.SyncSettings.KeepLastModifiedVersion; MergeExistingEntries = SyncProfile.SyncSettings.MergeExistingEntries; SyncFrequency = SyncProfile.SyncSettings.SyncFrequency.Name; SetCategory = SyncProfile.SetCalendarCategory; _selectedGoogleAccount = googleAccount; if (_selectedGoogleAccount != null) { SelectedCalendar = SelectedGoogleAccount.GoogleCalendar; } SelectedOutlookProfileName = SyncProfile.OutlookSettings.OutlookProfileName; SelectedOutlookMailBox = SyncProfile.OutlookSettings.OutlookMailBox; SelectedOutlookCalendar = SyncProfile.OutlookSettings.OutlookCalendar; if (SyncProfile.EventCategory != null) { SelectedCategory = Categories.First(t => t.CategoryName.Equals(SyncProfile.EventCategory.CategoryName)); } }
private void PopulateGoogleOptionMenu(GoogleAccountManager manager, GoogleAccount changed_account) { this.account = changed_account; int pos = -1; accounts = manager.GetAccounts (); if (accounts == null || accounts.Count == 0) { if (accounts == null) Log.Debug ("accounts == null"); else Log.Debug ("accounts != null"); Log.DebugFormat ("accounts.Count = {0}", accounts.Count); gallery_optionmenu.AppendText (Catalog.GetString ("(No Gallery)")); gallery_optionmenu.Sensitive = false; edit_button.Sensitive = false; pos = 0; } else { int i = 0; pos = 0; foreach (GoogleAccount account in accounts) { if (account == changed_account) pos = i; gallery_optionmenu.AppendText (account.Username); i++; } gallery_optionmenu.Sensitive = true; edit_button.Sensitive = true; } Log.DebugFormat ("Setting gallery_optionmenu.Active = {0}", pos); gallery_optionmenu.Active = pos; }
private void ReadAccounts() { Hashtable request_attributes = new Hashtable(); request_attributes["name"] = keyring_item_name; try { foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) { if(!result.Attributes.ContainsKey("name") || !result.Attributes.ContainsKey("username") || (result.Attributes["name"] as string) != keyring_item_name) continue; string username = (string)result.Attributes["username"]; string password = result.Secret; if (username == null || username == String.Empty || password == null || password == String.Empty) throw new ApplicationException ("Invalid username/password in keyring"); GoogleAccount account = new GoogleAccount(username, password); if (account != null) AddAccount (account, false); } } catch (Exception e) { Log.DebugException (e); } MarkChanged (); }
public void RemoveAccount(GoogleAccount account) { string keyring; try { keyring = Ring.GetDefaultKeyring(); } catch { return; } Hashtable request_attributes = new Hashtable(); request_attributes["name"] = keyring_item_name; request_attributes["username"] = account.Username; try { foreach(ItemData result in Ring.Find(ItemType.GenericSecret, request_attributes)) { Ring.DeleteItem(keyring, result.ItemID); } } catch (Exception e) { Log.DebugException (e); } accounts.Remove (account); MarkChanged (); }
public void MarkChanged(bool write, GoogleAccount changed_account) { if (write) WriteAccounts (); if (AccountListChanged != null) AccountListChanged (this, changed_account); }
public void AddAccount(GoogleAccount account, bool write) { accounts.Add (account); MarkChanged (write, account); }
public void AddAccount(GoogleAccount account) { AddAccount (account, true); }
private void Connect(GoogleAccount selected, string token, string text) { try { if (accounts.Count != 0 && connect) { if (selected == null) account = (GoogleAccount)accounts [gallery_optionmenu.Active]; else account = selected; if (!account.Connected) account.Connect (); PopulateAlbumOptionMenu (account.Picasa); long qu = account.Picasa.QuotaUsed; long ql = account.Picasa.QuotaLimit; StringBuilder sb = new StringBuilder ("<small>"); sb.Append (String.Format (Catalog.GetString ("Available space: {0}, {1}% used out of {2}"), GLib.Format.SizeForDisplay (ql - qu), (100 * qu / ql), GLib.Format.SizeForDisplay (ql))); sb.Append ("</small>"); status_label.Text = sb.ToString (); status_label.UseMarkup = true; album_button.Sensitive = true; } } catch (CaptchaException exc) { Log.Debug ("Your Google account is locked"); if (selected != null) account = selected; PopulateAlbumOptionMenu (account.Picasa); album_button.Sensitive = false; new GoogleAccountDialog (this.Dialog, account, false, exc); Log.Warning ("Your Google account is locked, you can unlock it by visiting: {0}", CaptchaException.UnlockCaptchaURL); } catch (System.Exception) { Log.Warning ("Can not connect to Picasa. Bad username? password? network connection?"); if (selected != null) account = selected; PopulateAlbumOptionMenu (account.Picasa); status_label.Text = String.Empty; album_button.Sensitive = false; new GoogleAccountDialog (this.Dialog, account, true, null); } }
private void Connect (GoogleAccount selected, string token, string text) { try { if (accounts.Count != 0 && connect) { if (selected == null) account = (GoogleAccount) accounts [gallery_optionmenu.History]; else account = selected; if (!account.Connected) account.Connect (); PopulateAlbumOptionMenu (account.Picasa); long qu = account.Picasa.QuotaUsed; long ql = account.Picasa.QuotaLimit; StringBuilder sb = new StringBuilder("<small>"); sb.Append(Catalog.GetString("Available space:")); sb.Append(SizeUtil.ToHumanReadable (ql - qu)); sb.Append(" ("); sb.Append(100 * qu / ql); sb.Append("% used out of "); sb.Append(SizeUtil.ToHumanReadable (ql)); sb.Append(")"); sb.Append("</small>"); status_label.Text = sb.ToString(); status_label.UseMarkup = true; album_button.Sensitive = true; } } catch (CaptchaException exc){ System.Console.WriteLine("Your google account is locked"); if (selected != null) account = selected; PopulateAlbumOptionMenu (account.Picasa); album_button.Sensitive = false; new GoogleAccountDialog (this.Dialog, account, false, exc); System.Console.WriteLine ("Your google account is locked, you can unlock it by visiting: {0}", CaptchaException.UnlockCaptchaURL); } catch (System.Exception) { System.Console.WriteLine ("Can not connect to Picasa. Bad username ? password ? network connection ?"); //System.Console.WriteLine ("{0}",ex); if (selected != null) account = selected; PopulateAlbumOptionMenu (account.Picasa); status_label.Text = String.Empty; album_button.Sensitive = false; new GoogleAccountDialog (this.Dialog, account, true, null); } }
private void Connect (GoogleAccount selected) { Connect (selected, null, null); }
public GoogleAccountDialog (Gtk.Window parent, GoogleAccount account, bool show_error, CaptchaException captcha_exception) { xml = new Glade.XML (null, "PicasaWebExport.glade", dialog_name, "f-spot"); xml.Autoconnect (this); Dialog.Modal = false; Dialog.TransientFor = parent; Dialog.DefaultResponse = Gtk.ResponseType.Ok; this.account = account; bool show_captcha = (captcha_exception != null); status_area.Visible = show_error; locked_area.Visible = show_captcha; captcha_label.Visible = show_captcha; captcha_entry.Visible = show_captcha; captcha_image.Visible = show_captcha; password_entry.ActivatesDefault = true; username_entry.ActivatesDefault = true; if (show_captcha) { try { using (ImageFile img = ImageFile.Create(new Uri(captcha_exception.CaptchaUrl))) { captcha_image.Pixbuf = img.Load(); token = captcha_exception.Token; } } catch (Exception) {} } if (account != null) { password_entry.Text = account.Password; username_entry.Text = account.Username; add_button.Label = Gtk.Stock.Ok; Dialog.Response += HandleEditResponse; } if (remove_button != null) remove_button.Visible = account != null; this.Dialog.Show (); password_entry.Changed += HandleChanged; username_entry.Changed += HandleChanged; HandleChanged (null, null); }
public IndexModel(GoogleAccount googleAccount) { _googleAccount = googleAccount; }
protected void HandleAddResponse (object sender, Gtk.ResponseArgs args) { if (args.ResponseId == Gtk.ResponseType.Ok) { GoogleAccount account = new GoogleAccount (username, password); GoogleAccountManager.GetInstance ().AddAccount (account); } Dialog.Destroy (); }
private async void DisconnectGoogleHandler(object parameter) { GoogleAccount googleAccount = parameter as GoogleAccount; if (googleAccount == null) { MessageService.ShowMessageAsync("No account selected"); return; } string accountName = googleAccount.Name; var dialogResult = await MessageService.ShowConfirmMessage( "Disconnection of Google account cannot be reverted.\nClick Yes to continue."); if (dialogResult == MessageDialogResult.Negative) { return; } var result = AccountAuthenticationService.DisconnectGoogle(googleAccount.Name); if (result) { foreach (var profile in Settings.CalendarSyncProfiles) { if (profile.GoogleSettings.GoogleAccount != null && profile.GoogleSettings.GoogleAccount.Name.Equals(googleAccount.Name)) { profile.GoogleSettings.GoogleAccount = null; profile.GoogleSettings.GoogleCalendar = null; profile.GoogleSettings.GoogleCalendars = null; } profile.IsLoaded = false; } //Remove google account googleAccount = Settings.GoogleAccounts.FirstOrDefault(account => account.Name == accountName); if (googleAccount != null) { Settings.GoogleAccounts.Remove(googleAccount); } googleAccount = _lastSavedSettings.GoogleAccounts.FirstOrDefault(account => account.Name == accountName); if (googleAccount != null) { _lastSavedSettings.GoogleAccounts.Remove(googleAccount); } await MessageService.ShowMessage("Google account successfully disconnected"); await SettingsSerializationService.SerializeSettingsAsync(_lastSavedSettings); } else { MessageService.ShowMessageAsync("Account wasn't authenticated earlier or disconnection failed."); } }
public GoogleDataStore(GoogleAccount account, IRepository repository) { _account = account; _repository = repository; }
private void PopulateGoogleOptionMenu (GoogleAccountManager manager, GoogleAccount changed_account) { Gtk.Menu menu = new Gtk.Menu (); this.account = changed_account; int pos = -1; accounts = manager.GetAccounts (); if (accounts == null || accounts.Count == 0) { Gtk.MenuItem item = new Gtk.MenuItem (Catalog.GetString ("(No Gallery)")); menu.Append (item); gallery_optionmenu.Sensitive = false; edit_button.Sensitive = false; } else { int i = 0; foreach (GoogleAccount account in accounts) { if (account == changed_account) pos = i; Gtk.MenuItem item = new Gtk.MenuItem (account.Username); menu.Append (item); i++; } gallery_optionmenu.Sensitive = true; edit_button.Sensitive = true; } menu.ShowAll (); gallery_optionmenu.Menu = menu; gallery_optionmenu.SetHistory ((uint)pos); }