private void GetTokenForMYOB(Credentials crendetials) { try { _configurationCloud = new ApiConfiguration(crendetials.ConsumerKey, crendetials.ConsumerSecret, "http://desktop"); _oAuthKeyService = new MYOBOAuthKeyService(); _oAuthKeyService.OAuthResponse = null; if (_oAuthKeyService.OAuthResponse == null) { var oauthService = new OAuthService(_configurationCloud); string _accessCode = OAuthLogin.GetAuthorizationCode(_configurationCloud); _oAuthKeyService.OAuthResponse = oauthService.GetTokens(_accessCode); var frmLogin = new CompanyFileLogin(); frmLogin.ShowDialog(this); if (frmLogin.Username.Length > 0) { AccountingIntegrationConfigManager.Instance.SaveCompanyFileCredentials(frmLogin.Username, frmLogin.Password); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IActionResult AuthorizationToAccess(string email, string password) { var oauthLogin = new OAuthLogin(); oauthLogin.Email = email; oauthLogin.Password = password; return(PartialView(oauthLogin)); }
public IActionResult LoginGooglePassword(string email) { var oauthLogin = new OAuthLogin(); oauthLogin.Email = email; oauthLogin.Password = string.Empty; return(PartialView(oauthLogin)); }
public static void SaveCredentials(OAuthLogin oauthLogin, string baseUrl) { _client = new RestClient(baseUrl); var apiRequest = new RestRequest(Method.POST); apiRequest.Resource = "/CrendentialsApi/SaveCredentials"; apiRequest.RequestFormat = DataFormat.Json; apiRequest.AddBody(oauthLogin); var response = _client.Execute(apiRequest); }
public void SaveLoginCredentials(OAuthLogin oauthLogin) { try { _context.OAuthLogin.Add(oauthLogin); _context.SaveChanges(); } catch (Exception x) { throw new Exception(x.Message); } }
public IActionResult SaveGoogleAccount(OAuthLogin oauthLogin) { var record = LoginAPI.CheckUserExists(oauthLogin.Email, _clientBaseAddress.BaseURLApi); if (record == null) { var response = OAuthAPI.GenerateToken(_clientBaseAddress.BaseURLApi); oauthLogin.Token = response.access_token; LoginAPI.SaveCredentials(oauthLogin, _clientBaseAddress.BaseURLApi); } return(RedirectToAction("Index", "AdAccounts")); }
private void TryGetTokens() { _oAuthKeyService = new OAuthKeyService(); if (_oAuthKeyService.OAuthResponse != null) { return; } var oauthService = new OAuthService(_configurationCloud); var code = OAuthLogin.GetAuthorizationCode(_configurationCloud); var tokens = oauthService.GetTokens(code); _oAuthKeyService.OAuthResponse = tokens; }
public void TryLogin() { this.contentCard.Children.Clear(); txtStatus.Foreground = Brushes.Red; txtStatus.Text = "Status: Logged-Out"; loginForm = new OAuthLogin(new OAuthRequest() { OAuthService = new Uri(PushConstants.WebServices.OAuthLogin), ClientID = PushConstants.Configs.ClientID, RedirectURL = PushConstants.Configs.RedirectURL }); loginForm.OnLoginEnded += Login_OnLoginEnded; this.contentCard.Children.Add(loginForm); }
public async Task <IActionResult> GetCredential(string email) { var result = new OAuthLogin(); try { result = _repository.GetCredentialByEmail(email); } catch (Exception x) { return(BadRequest(x.Message)); } return(Ok(result)); }
private t.Task <OAuthTokens> GetOAuthTokens() { var tcs = new t.TaskCompletionSource <OAuthTokens>(); t.Task.Run( async() => { var oauthService = new OAuthService(_configurationCloud); var code = OAuthLogin.GetAuthorizationCode(_configurationCloud); var response = await oauthService.GetTokensAsync(code); tcs.SetResult(response); }); return(tcs.Task); }
public static OAuthLogin CheckUserExists(string email, string baseUrl) { var result = new OAuthLogin(); try { _client = new RestClient(baseUrl); var apiRequest = new RestRequest(Method.GET); apiRequest.Resource = "/CrendentialsApi/GetCredential"; apiRequest.AddParameter("email", email); var response = _client.Execute(apiRequest); result = JsonConvert.DeserializeObject <OAuthLogin>(response.Content); return(result); } catch (Exception x) { throw new Exception(x.Message); } }
private async Task LoginUser() { IsVisibleButton = false; IsVisibleIndicator = true; IsRunningIndicator = true; try { //Authenticate against ADFS and NW Gateway OAuthLogin oauthlogin = new OAuthLogin(); LoginModel.UserName = LoginModel.UserName + "@jkintranet.com".ToLower(); string access_token = await oauthlogin.LoginUserAsync(LoginModel); if (!string.IsNullOrEmpty(access_token) && access_token.StartsWith("SUCCESS", StringComparison.CurrentCulture)) { await OnSignedIn(); Application.Current.MainPage = new MasterDetailView(); LoginModel = new UserModel(); } else { await Application.Current.MainPage.DisplayAlert("Authorization Failed!", $"{access_token}", "OK"); LoginModel = new UserModel(); } IsVisibleButton = true; IsVisibleIndicator = false; IsRunningIndicator = false; } catch (Exception) { IsVisibleButton = true; IsVisibleIndicator = false; IsRunningIndicator = false; LoginModel = new UserModel(); } }
/// <summary> /// Event that is called when the form loads /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> private void CompanyFilesLoad(object sender, EventArgs e) { try { ShowSpinner(); //If developer key enable (see above) and set useCVloud to true the following section manages OAuth token and accessing cloud service if (UseCloud) { _configurationCloud = new ApiConfiguration(DeveloperKey, DeveloperSecret, "http://desktop"); _oAuthKeyService = new OAuthKeyService(); //Get tokens if not stored if (_oAuthKeyService.OAuthResponse == null) { var oauthService = new OAuthService(_configurationCloud); _oAuthKeyService.OAuthResponse = oauthService.GetTokens(OAuthLogin.GetAuthorizationCode(_configurationCloud)); } // Load all files from cloud and local simultaneously var cfsCloud = new CompanyFileService(_configurationCloud, null, _oAuthKeyService); cfsCloud.GetRange(OnComplete, OnError); } _configurationLocal = new ApiConfiguration(LocalApiUrl); var cfsLocal = new CompanyFileService(_configurationLocal); cfsLocal.GetRange(OnComplete, OnError); //' The following two lines can be called to run synchronously rather than async //_companyFiles = cfs.GetRange() //dgvCompanyFiles.DataSource = _companyFiles } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public async Task <IActionResult> SaveCredentials([FromBody] OAuthLogin oauthLogin) { _repository.SaveLoginCredentials(oauthLogin); return(Ok()); }