public bool AddAuthUser(String shortUserID) { var uList = allUsers.Where(item => item.shortID == shortUserID).ToList(); if (uList != null && uList.Count > 0) { var userToAdd = uList[0]; if (AllowedUsers.Contains(userToAdd)) { return(true); //already allowed to view } UserAuthorizations userAuthorizations = new UserAuthorizations(); userAuthorizations.TherapistID = Login.Default.CurrentUser.id; userAuthorizations.AuthorizedToViewUserID = userToAdd.id; _azureDataService.AddAuthUser(userAuthorizations); //doesn't wait AllowedUsers.Add(userToAdd); return(true); } else { return(false); } }
/// <summary> /// Get Access Token which is used to into All API functions /// In case of error return error string /// </summary> /// <returns>Access Token String</returns> public string GetAccessToken() { try { if (AccessToken != "") { return(AccessToken); } else ///*** Issue New one { UserAuthorizations.Authorize(_authorization, _endpoint, _clientId, _clientSecret, _callbackUrl, _AuthorizationUri); AccessToken = _authorization.AccessToken; return(_authorization.AccessToken); } } catch (Exception e) //*** Error { MsgError = e.ToString(); return(""); //return null; } }
public string GetOAuthAuthenticationToken() { UserAuthorizations.Authorize(Authorization, EndPoint, ExactOnlineClientId, ExactOnlineClientSecret, _redirectUri); return(Authorization.AccessToken); }
public string GetAccessToken() { UserAuthorizations.Authorize(_authorization, EndPoint, _clientId, _clientSecret, _callbackUrl); return(_authorization.AccessToken); }
public async Task RemoveAuthUsers(UserAuthorizations user) { await _userAuthorizations.DeleteAsync(user); await SyncAuthUsers(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { try { #region Dropbox if (AuthType == AuthenticateTypeList.Dropbox) { this.Title = "Dropbox Authentication"; this.db_Oauth2State = Guid.NewGuid().ToString("N"); var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, db_AppKey, new Uri(db_RedirectUri), state: db_Oauth2State); this.webBrowser.Navigate(authorizeUri); } #endregion Dropbox #region Exact Online if (AuthType == AuthenticateTypeList.ExactOnline) { this.Title = "Exact Online Authentication"; eo_Authorization = new UserAuthorization(); try { UserAuthorizations.Authorize(eo_Authorization, eo_EndPoint, eo_ClientId, eo_ClientSecret, new Uri(eo_CallbackUrl)); } catch (Exception) { MessageBox.Show("Invalid Exact Online's Client Secret!"); this.Result = false; this.Close(); return; } eo_AccessToken = eo_Authorization.AccessToken; if (eo_AccessToken == null) { this.Result = false; this.Close(); return; } else { this.Result = true; try { eo_Client = new ExactOnlineClient(eo_EndPoint, GetAccessToken); } catch (Exception) { MessageBox.Show("Invalid Exact Online's End Point!"); this.Result = false; this.Close(); return; } this.Close(); return; } } #endregion Exact Online } catch (Exception ex) { MessageBox.Show(ex.ToString()); this.Result = false; this.Close(); } }
private static IHandlerMapper InitApi(ConfigurationProviderBase prov) { string root = "api/"; VerbRestrictingMatchRule verbs = new VerbRestrictingMatchRule(HttpVerbs.GET.ToString(), HttpVerbs.POST.ToString()); UrlBaseMatchRule url = new UrlBaseMatchRule(new string[] { root }); verbs.NextMatcher = url; ServerRouting router = new ServerRouting(); SessionIdHeader head = new SessionIdHeader(); head.Next = router; MatchRuleMapHandler mapper = new MatchRuleMapHandler(head, verbs); //add all other handlers Session s = new Session(); router.Map.Add(new UrlBaseMapHandler(s, root + s.BaseUrl)); Login l = new Login(); router.Map.Add(new UrlBaseMapHandler(l, root + l.BaseUrl)); UserAuthorizations au = new UserAuthorizations(); router.Map.Add(new UrlBaseMapHandler(au, root + au.BaseUrl)); UserAffiliationHandler uah = new UserAffiliationHandler(); router.Map.Add(new UrlBaseMapHandler(uah, root + uah.BaseUrl)); Request req = new Request(); router.Map.Add(new UrlBaseMapHandler(req, root + req.BaseUrl)); OrganizationHandler orgs = new OrganizationHandler(); router.Map.Add(new UrlBaseMapHandler(orgs, root + orgs.BaseUrl)); SitesHandler sites = new SitesHandler(); router.Map.Add(new UrlBaseMapHandler(sites, root + sites.BaseUrl)); ProjectsHandler projs = new ProjectsHandler(); router.Map.Add(new UrlBaseMapHandler(projs, root + projs.BaseUrl)); FieldActivitiesHandler fas = new FieldActivitiesHandler(); router.Map.Add(new UrlBaseMapHandler(fas, root + fas.BaseUrl)); FileTransferHandler fts = new FileTransferHandler(); router.Map.Add(new UrlBaseMapHandler(fts, root + fts.BaseUrl)); InstrumentsHandler inst = new InstrumentsHandler(); router.Map.Add(new UrlBaseMapHandler(inst, root + inst.BaseUrl)); PersonsHandler per = new PersonsHandler(); router.Map.Add(new UrlBaseMapHandler(per, root + per.BaseUrl)); TaxaHandler tax = new TaxaHandler(); router.Map.Add(new UrlBaseMapHandler(tax, root + tax.BaseUrl)); WQHandler wq = new WQHandler(); router.Map.Add(new UrlBaseMapHandler(wq, root + wq.BaseUrl)); FishHandler fish = new FishHandler(); router.Map.Add(new UrlBaseMapHandler(fish, root + fish.BaseUrl)); VegetationHandler veg = new VegetationHandler(); router.Map.Add(new UrlBaseMapHandler(veg, root + veg.BaseUrl)); EntityBundlesHandler ebh = new EntityBundlesHandler(); router.Map.Add(new UrlBaseMapHandler(ebh, root + ebh.BaseUrl)); DetsHandler det = new DetsHandler(); router.Map.Add(new UrlBaseMapHandler(det, root + det.BaseUrl)); return(mapper); }
public string GetAccessToken() { UserAuthorizations.Authorize(userAuthorisation, website, clientId, clientSecret, new Uri(@"http://localhost:12345/oauth2callback")); return(userAuthorisation.AccessToken); }