public void DeleteCredentials() { var account = _accountStore.FindAccountsForService(_AppName).FirstOrDefault(); if (account != null) { _accountStore.Delete(account, _AppName); } }
public async Task <bool> HasAccessToken(string clientId, string serviceId, CancellationToken cancellationToken) { return(await Task.Factory.StartNew(() => { var normalizedUsername = NormalizeClientId(clientId); var account = _accountStore.FindAccountsForService(serviceId).FirstOrDefault(a => string.Equals(a.Username, normalizedUsername, StringComparison.CurrentCultureIgnoreCase)); return account != null; }, cancellationToken).ConfigureAwait(false)); }
/// <summary> /// Adds a credential to the Credential Locker. /// </summary> /// <param name="resource">The resource for which the credentials are used.</param> /// <param name="userName">The user name that must be present in the credentials.</param> /// <param name="password">The password for the created credentials.</param> /// <exception cref="ArgumentNullException">Dispatched when <paramref name="resource"/>, <paramref name="userName"/> or /// <paramref name="password"/> is <c>Null</c> /// </exception> public bool CreateAccount(string resource, string userName, string password) { if (string.IsNullOrEmpty(resource)) { throw new ArgumentNullException(nameof(resource), "The argument is null"); } if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException(nameof(userName), "The argument is null"); } if (string.IsNullOrEmpty(password)) { throw new ArgumentNullException(nameof(password), "The argument is null"); } try { account = new Account { Username = userName }; account.Properties.Add(resource, password); vault.Save(account, AppName); var lista = vault.FindAccountsForService(AppName); return(true); } catch (Exception e) { return(false); } }
public Authenticator() { accountStore = AccountStore.Create(); var accounts = accountStore.FindAccountsForService(CREDENTIALS_NAME); account = accounts.FirstOrDefault(); }
public LoginPage() { InitializeComponent(); Init(); store = AccountStore.Create(); account = store.FindAccountsForService(AppAuthenParameters.AppName).FirstOrDefault(); }
private void GoogleButton_TouchUpInside(object sender, EventArgs e) { store = AccountStore.Create(); string clientId = "702647090904-45v1qskciukrf1ojmnotljnmk9k7ph23.apps.googleusercontent.com"; string redirectUri = "com.buptis.app.ios:/oauth2redirect"; account = store.FindAccountsForService("Buptis").FirstOrDefault(); var authenticator = new OAuth2Authenticator( clientId, null, "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile", //https://www.googleapis.com/auth/userinfo.profile //SADECE EMAİL GELİYOR BAK BUNA new Uri("https://accounts.google.com/o/oauth2/auth"), new Uri(redirectUri), new Uri("https://www.googleapis.com/oauth2/v4/token"), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; //GoogleVC = authenticator.GetUI(); //this.PresentViewController(GoogleVC, true, null); AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
public static async Task <bool> ValidateLoginAsync() { AccountStore accountStore = AccountStore.Create(); Account account = accountStore.FindAccountsForService(_servideId).SingleOrDefault(); if (account != null) { bool result = await RestService.Instance.ValidateTokenAsync(account.Properties["Token"]); if (result) { Account = new AuthModel { Token = account.Properties["Token"], ExpiresIn = account.Properties["ExpiresIn"], IdUser = account.Properties["IdUser"], UserName = account.Properties["UserName"], UserPhone = account.Properties["UserPhone"], IdSocialNetwork = account.Properties["IdSocialNetwork"], AuthType = (AuthType)Enum.Parse(typeof(AuthType), account.Properties["AuthType"]), ExpirationDate = DateTime.Now + TimeSpan.FromSeconds(Convert.ToDouble(account.Properties["ExpiresIn"])) }; } return(result); } return(false); }
public string Fetch(string keyString) { try { var fetchedAccount = _accountStore.FindAccountsForService(_serviceIdstring).FirstOrDefault(); if (fetchedAccount == null) { return(null); } _account = fetchedAccount; var hasKey = _account.Properties?.ContainsKey(keyString); if (hasKey == false) { return(null); } var valueString = _account.Properties?[keyString]; return(valueString); } catch (AccountStoreException exception) { Console.WriteLine(exception.StackTrace); return(null); } }
private void signinGoogle_Clicked(System.Object sender, System.EventArgs e) { string clientId = null; string redirectUrl = null; switch (Device.RuntimePlatform) { case Device.Android: clientId = Constants.AndroidClientId; redirectUrl = Constants.AndroidRedirectUrl; break; } account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); var authenticator = new OAuth2Authenticator( clientId, null, Constants.Scope, new Uri(Constants.AuthorizeUrl), new Uri(redirectUrl), new Uri(Constants.AccessTokenUrl), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); }
public IEnumerable <LeanKitAccount> GetAll() { var accounts = _accountStore.FindAccountsForService(_applicationSettings.AppName); var lkAccounts = new List <LeanKitAccount>(); foreach (var account in accounts) { long userId; if (long.TryParse(account.Username, out userId)) { var organization = account.Properties["Organization"].FromJson <OrganizationLink>(); var authorizationType = (AuthorizationType)Enum.Parse(typeof(AuthorizationType), account.Properties["AuthorizationType"]); lkAccounts.Add(new LeanKitAccount(userId, account.Properties["UserName"], account.Properties["Secret"], authorizationType, organization, account.Properties["AvatarUrl"])); } else { //delete the legacy accounts when username was the account "key" _accountStore.Delete(account, _applicationSettings.AppName); } } return(lkAccounts); }
public LoginPage() { InitializeComponent(); store = AccountStore.Create(); account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); }
public AuthToken getToken() { var account = store.FindAccountsForService(context).FirstOrDefault(); if (account == null) { return(null); } else { var token = new AuthToken(); token.accessToken = account.Username; if (account.Properties.ContainsKey("expires_in")) { token.expiresIn = account.Properties ["expires_in"]; } if (account.Properties.ContainsKey("token_type")) { token.tokenType = account.Properties ["token_type"]; } if (account.Properties.ContainsKey("scope")) { token.scope = account.Properties ["scope"]; } if (account.Properties.ContainsKey("refresh_token")) { token.refreshToken = account.Properties ["refresh_token"]; } return(token); } }
public LoginViewModel() { User = new UserInfo(); store = AccountStore.Create(); account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); //OnGoogleButtonCommand = new Command(OnGoogleButtonClick); }
static AuthenticationService() { TokenEndpoint = new Uri($"{App.Settings.Identity.Url}connect/token"); AccountStore = AccountStore.Create(); AuthAccount = AccountStore .FindAccountsForService(App.Settings.ServiceId) .FirstOrDefault(); }
public AccountService(HttpClient client) { _accountRepository = new AccountRepository(client); _accountTokenRepository = new AccountTokenRepository(client); AccountStore = AccountStore.Create(); XamarinAccount = AccountStore.FindAccountsForService(Constants.AppName).FirstOrDefault(); }
public Login() { InitializeComponent(); // objetos do tipo Account para um serviço podem ser recuperados // chamando o método FindAccountsForService, que retorna uma coleção // de objectos Account, com o primeiro item sendo o procurado. store = AccountStore.Create(); account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); }
public LoginPage() { InitializeComponent(); _store = AccountStore.Create(); _account = _store.FindAccountsForService(Constants.AppName).FirstOrDefault(); btnLogin.Clicked += OnAuth; btnFacebookLogin.Clicked += OnFacebookLogin; }
public static void DeleteAccount() { AccountStore accountStore = AccountStore.Create(); Account account = accountStore.FindAccountsForService(_servideId).SingleOrDefault(); if (account != null) { accountStore.Delete(account, _servideId); } }
public Account CheckForAccount() { AccountStore store = GetAccountStore(); var accounts = store.FindAccountsForService(serviceID); //store.Delete(accounts.FirstOrDefault(), serviceID); return(accounts.FirstOrDefault()); }
void OnGoogleLoginClicked(object sender, EventArgs e) { string clientId = null; string redirectUri = null; //Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = null; switch (Device.RuntimePlatform) { case Device.iOS: clientId = Constants.GoogleiOSClientId; redirectUri = Constants.GoogleiOSRedirectUrl; break; case Device.Android: clientId = Constants.GoogleAndroidClientId; redirectUri = Constants.GoogleAndroidRedirectUrl; break; } account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); var authenticator = new OAuth2Authenticator( clientId, null, Constants.GoogleScope, new Uri(Constants.GoogleAuthorizeUrl), new Uri(redirectUri), new Uri(Constants.GoogleAccessTokenUrl), null, true); authenticator.Completed += OnAuthCompleted; authenticator.Error += OnAuthError; AuthenticationState.Authenticator = authenticator; var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter(); presenter.Login(authenticator); btnGoogle.Text = "Authenticating..."; btnGoogle.IsEnabled = false; }
private Task <AccessToken> GetAccessToken(string normalizedUsername, string serviceId, CancellationToken cancellationToken) { return(Task.Factory.StartNew(() => { var account = _accountStore.FindAccountsForService(serviceId) .First(a => string.Equals(a.Username, normalizedUsername, StringComparison.CurrentCultureIgnoreCase)); return new AccessToken(account.Properties); }, cancellationToken)); }
protected override void ClearCredentials() { AccountStore acStore = AccountStore.Create(context); IEnumerable <Account> accounts = acStore.FindAccountsForService(SERVICE_ID); foreach (Account account in accounts) { acStore.Delete(account, SERVICE_ID); } base.ClearCredentials(); }
public App() { InitializeComponent(); accountStore = AccountStore.Create(); account = accountStore.FindAccountsForService(APP_NAME).FirstOrDefault(); MainPage = new MainPage(); //App.DB.Create(new QnectMe.Models.Account() { Name = "Art James", Number = "111-123-123", LI = "mariam-antonyan-a0a35b104", FB = "Mete0rka", Company = "Apple", Email = "*****@*****.**", Skype = "MySkypeID" }); //App.DB.Create(new QnectMe.Models.Account() { Name = "Bob Fill", Number = "222-3242-2432", LI = "mohammad-sadegh-dabestani-51b63587", FB = "flogger.morozov", Company = "Nokia", Email = "*****@*****.**", Skype = "MySkypeID" }); //App.DB.Create(new QnectMe.Models.Account() { Name = "Gyn Man", Number = "333-23423-2423", LI = "александр-челомбитько-536a85b3", FB = "SergeySA81", Company = "UMC", Email = "*****@*****.**", Skype = "MySkypeID" }); }
public ArtportalenAccountStorage(ICurrentUser currentUser) { _currentUser = currentUser; #if __ANDROID__ _accountStore = AccountStore.Create(Forms.Context); #endif #if __IOS__ _accountStore = AccountStore.Create(); #endif _account = _accountStore.FindAccountsForService(ServiceId).FirstOrDefault(a => a.Username == _currentUser.Id); }
Account GetAccountFromStore(AccountStore store, string username) { if (store == null || username == null) { return(null); } var accounts = store.FindAccountsForService(serviceID); return(accounts.FirstOrDefault(a => a.Username == username)); }
public Login() { InitializeComponent(); var facebook = botonFacebook; var google = botonGoogle; store = AccountStore.Create(); facebook.GestureRecognizers.Add(new TapGestureRecognizer(loginFacebook)); google.GestureRecognizers.Add(new TapGestureRecognizer(GoogleLoginClicked)); account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); }
public MainPage() { InitializeComponent(); implicitButton.Clicked += ImplicitButtonClicked; authorizationCodeButton.Clicked += AuthorizationCodeButtonClicked; getProfileButton.Clicked += GetProfileButtonClicked; refreshButton.Clicked += RefreshButtonClicked; store = AccountStore.Create(); account = store.FindAccountsForService(ServiceId).FirstOrDefault(); }
public Login() { InitializeComponent(); viewModel = new LoginViewModel(); this.BindingContext = viewModel; // objetos do tipo Account para um serviço podem ser recuperados chamando o método // FindAccountsForService. O método retorna uma coleção IEnumerable de objectos Account, // com o primeiro item sendo o Account procurado. store = AccountStore.Create(); account = store.FindAccountsForService(Constants.AppName).FirstOrDefault(); }
public void RemoveTokenFromSecureStore() { var accounts = AccountStore.FindAccountsForService("tasklist"); if (accounts != null) { foreach (var acct in accounts) { AccountStore.Delete(acct, "tasklist"); } } }
public void RemoveTokenFromSecureStore() { var accounts = AccountStore.FindAccountsForService(Locations.AppName); if (accounts != null) { foreach (var acct in accounts) { AccountStore.Delete(acct, Locations.AppName); } } }
public CredentialStore() { store = AccountStore.Create(); var records = store.FindAccountsForService (context); }