private void Window_Initialized(object sender, EventArgs e) { try { var tokenCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "droptoken"); var secretCachePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "dropsecret"); if (File.Exists(tokenCachePath) && File.Exists(secretCachePath)) { var cachedUserToken = File.ReadAllText(tokenCachePath); var cachedUserSecret = File.ReadAllText(secretCachePath); _client = new DropNetClient(appKey, appSecret, cachedUserToken, cachedUserSecret); } else { _client = new DropNetClient(appKey, appSecret); var userToken = _client.GetToken(); var tokenUrl = _client.BuildAuthorizeUrl("http://localhost:8000/token"); browser1.DocumentCompleted += Browser1OnDocumentCompleted; browser1.Navigated += Browser1OnNavigated; browser1.ScriptErrorsSuppressed = true; browser1.Navigate(new Uri(tokenUrl)); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); } }
public static void Main() { var client = new DropNetClient(DropboxAppKey, DropboxAppSecret); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Console.WriteLine("COPY?PASTE Link: {0}", url); Console.WriteLine("Press enter when clicked allow"); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", url); Console.ReadLine(); var accessToken = client.GetAccessToken(); client.UseSandbox = true; var metaData = client.CreateFolder("NewUpload" + DateTime.Now.ToString()); string[] dir = Directory.GetFiles("../../images/", "*.JPG"); foreach (var item in dir) { Console.WriteLine("Reading file....."); FileStream stream = File.Open(item, FileMode.Open); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); Console.WriteLine(bytes.Length + " bytes uploading..."); client.UploadFile("/" + metaData.Name.ToString(), item.Substring(6), bytes); Console.WriteLine("{0} uploaded!", item); stream.Close(); } Console.WriteLine("Job Done!"); var picUrl = client.GetShare(metaData.Path); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", picUrl.Url); }
public string AskForRegistrationUrl(UserProfileInfo user, string redirectUrl, out int tempCredentialId) { var _client = new DropNetClient(MogConstants.DROPBOX_KEY, MogConstants.DROPBOX_SECRET); UserLogin login = _client.GetToken(); // UserLogin login = _client.GetAccessToken(); var url = _client.BuildAuthorizeUrl(login, redirectUrl); var query = repoAuthCredential.GetByUserId(user.Id); List<AuthCredential> existingCredentials = null; if (query != null) {//TODO : gerer le cas des accounts multiples existingCredentials = query.Where(a => a.CloudService == CloudStorageServices.Dropbox).ToList(); foreach (var credential in existingCredentials) { repoAuthCredential.Delete(credential); } } AuthCredential newCredential = new AuthCredential(); newCredential.Token = login.Token; newCredential.Secret = login.Secret; newCredential.UserId = user.Id; newCredential.CloudService = CloudStorageServices.Dropbox; this.repoAuthCredential.Create(newCredential); tempCredentialId = newCredential.Id; return url; }
internal DropboxModel() { try { DropNetClient client = new DropNetClient("763s7xzmvkxmfkn", "dzl7p8qdt0p1f5v"); client.GetToken(); string url = client.BuildAuthorizeUrl(); Process proc = Process.Start("iexplore", url); bool authenticated = false; while (!authenticated) { System.Threading.Thread.Sleep(5000); try { client.GetAccessToken(); } catch { } authenticated = true; } this.client = client; } catch (Exception ex) { LogController.AddEntryDropbox(string.Format("Unable to authenticate user: {0}", ex.Message)); throw new Exception("Authentication failed"); } }
static void Main(string[] args) { Console.WriteLine("You must first login in your dropbox account."); string currentDir = Directory.GetCurrentDirectory(); DirectoryInfo info = new DirectoryInfo(currentDir).Parent.Parent; FileInfo[] pictures = info.GetFiles("*.jpg"); List<int> indexesOfChosen = new List<int>(); PrintAndChoosePictures(pictures, indexesOfChosen); DropNetClient client = new DropNetClient("8lc93q5ybq85syv", "nt6wrs7m0maixnl"); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Clipboard.SetText(url); Console.WriteLine("\n\nUrl copied to clipboard. Paste in browser and allow.\nPress any key to continue", url); Console.ReadKey(true); var accessToken = client.GetAccessToken(); client.UserLogin.Secret = accessToken.Secret; client.UserLogin.Token = accessToken.Token; client.UseSandbox = true; Console.Write("Enter album name: "); var albumName = Console.ReadLine(); var folder = client.CreateFolder(albumName); Console.WriteLine("\nUploading...\n"); foreach (var i in indexesOfChosen) { MemoryStream sr = new MemoryStream((int)pictures[i].Length); FileStream fs = File.Open(pictures[i].FullName, FileMode.Open); var bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); client.UploadFile(folder.Path, pictures[i].Name, bytes); fs.Close(); } var shareUrl = client.GetShare(folder.Path); Clipboard.SetText(shareUrl.Url); Console.WriteLine(shareUrl.Url); Console.WriteLine("Share Url is also in clipboard"); }
private void Group1NextButtonClick(object sender, EventArgs e) { groupBox1.Enabled = false; _client = new DropNetClient(AppKey.Text, AppSecret.Text); _client.UserLogin = _client.GetToken(); webBrowser.Navigate(_client.BuildAuthorizeUrl()); groupBox2.Enabled = true; }
public string GetAuthorizationUrl() { DropNetClient _client = new DropNetClient(AppConstants.DropboxClientId, AppConstants.DropboxClientSecret); var token = _client.GetToken(); Storage.Dropbox.Token = token; var url = _client.BuildAuthorizeUrl(RedirectUrl + "?dropboxcallback=1"); return url; }
public void fire_up_the_client() { var dropnet = new DropNetClient(ApiKey, AppSecret); var uselogin = dropnet.GetToken(); Debug.WriteLine("Token: " + uselogin.Token); Debug.WriteLine("Secret: " + uselogin.Secret); var url = dropnet.BuildAuthorizeUrl(uselogin); Debug.WriteLine("Url: " + url); //Authorize App var token = dropnet.GetAccessToken(); Debug.WriteLine("UsrToken: " + token.Token); Debug.WriteLine("UsrSecret: " + token.Secret); }
/// <summary> /// Logs in to dropbox. /// </summary> /// <returns>Drop box client object.</returns> private static DropNetClient DropBoxLogIn() { DropNetClient client = new DropNetClient(APP_KEY, APP_SECRET); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Console.WriteLine("Copy paste the link in your browser. Press any key when done."); Console.WriteLine(url); Console.ReadKey(); var accessToken = client.GetAccessToken(); client.UserLogin.Secret = accessToken.Secret; client.UserLogin.Token = accessToken.Token; client.UseSandbox = true; return client; }
public static void Main() { var client = new DropNetClient(apiKey, apiSecret); client.GetToken(); var url = client.BuildAuthorizeUrl(); Console.WriteLine("Open \"{0}\" in browser.", url); Console.WriteLine("Press [Enter] when you click on [Allow]"); OpenBrowser(url); Console.ReadLine(); client.GetAccessToken(); client.UseSandbox = true; var metaData = client.CreateFolder("HW-Pictures - " + date); string[] dir = Directory.GetFiles("../../images/", "*.jpg"); foreach (var file in dir) { Console.Write("Uploading"); while (true) { FileStream stream = File.Open(file, FileMode.Open); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); client.UploadFile("/" + metaData.Name, file.Substring(6), bytes); for (var i = 0; i < 10; i++) { Console.Write("."); Thread.Sleep(300); } stream.Close(); Console.WriteLine(); break; } } Console.WriteLine("Done!"); var pictureUrl = client.GetShare(metaData.Path); OpenBrowser(pictureUrl.Url); }
public DropStorage(Action<string> webViewCallback) { _webViewCallback = webViewCallback; _client = new DropNetClient(DROPBOX_APP_KEY, DROPBOX_APP_SECRET); //Get Request Token _client.GetToken(); var authUri = _client.BuildAuthorizeUrl(); //Process.Start(authUri); _webViewCallback(authUri); //don't need it, web view callback is blocking //var dlg = new AuthDlg(StorageType.Dropbox); //dlg.ShowDialog(); _accessToken = _client.GetAccessToken(); //Store this token for "remember me" function }
private void Window_Loaded(object sender, RoutedEventArgs e) { _client = new DropNetClient("zta6zq4gmjrjz6y", "30qfyt4yzwcltlj"); if (File.Exists("accessToken.json")) { var json = File.ReadAllText("accessToken.json"); _accessToken = JsonConvert.DeserializeObject<UserLogin>(json); _client.UserLogin = _accessToken; GetMetaData(); } else { _client.GetToken(); var url = _client.BuildAuthorizeUrl(); dropboxPermissionsPanel.Visibility = Visibility.Visible; regularPanel.Visibility = Visibility.Hidden; webBrowser.Navigate(url); } }
public static void Main() { var client = new DropNetClient(DropboxAppKey, DropboxAppSecret); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Console.WriteLine("Open browser with in : {0}", url); Console.WriteLine("Press enter when clicked allow"); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", url); Console.ReadLine(); var accessToken = client.GetAccessToken(); client.UseSandbox = true; var metaData = client.CreateFolder("Pictures" + DateTime.Now); var dir = Directory.GetFiles("../../Photos", "*.jpg"); foreach (var item in dir) { Console.WriteLine("Uploading....."); var stream = File.Open(item, FileMode.Open); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, (int)stream.Length); client.UploadFile("/" + metaData.Name, item.Substring(6), bytes); stream.Close(); } var picUrl = client.GetShare(metaData.Path); Process.Start(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", picUrl.Url); }
public static void syncAcc(bool resync) { //Testing Connection try { Ping pSender = new Ping(); PingReply pResult = pSender.Send("8.8.8.8"); if (pResult.Status == IPStatus.Success) { Console.WriteLine("Internet available"); } else { Exception exc = new Exception("no internetconnection"); throw exc; } } catch (Exception) { MessageBox.Show("Please make sure your connection to the internet is available"); return; } DropNetClient dbClient = new DropNetClient(Program.Config.AppKey, Program.Config.AppSecret); #if DEBUG dbClient.UseSandbox = true; #endif if (String.IsNullOrEmpty(Properties.Settings.Default.DropBoxUserToken) || resync) { try { dbClient.GetToken(); } catch (Exception) { throw; } var url = dbClient.BuildAuthorizeUrl(); Browser_frm browser = new Browser_frm(); browser.Navigate(url,false); browser.ShowDialog(); try { var accessToken = dbClient.GetAccessToken(); MessageBox.Show(accessToken.Token); Properties.Settings.Default.DropBoxUserSecret = accessToken.Secret; Properties.Settings.Default.DropBoxUserToken = accessToken.Token; Properties.Settings.Default.Save(); MessageBox.Show("Login Saved"); } catch (Exception) { throw; } } else { MessageBox.Show("already synchronized"); } }
private void Login() { try { if (_client == null) { _client = new DropNetClient(AppKey, AppSecret); _client.GetToken(); } var url = _client.BuildAuthorizeUrl(Server); _miniWebServer = new MiniWebServer(SendResponse, Server); _miniWebServer.Run(); PhotoUtils.Run(url); } catch (Exception) { Log.Error("Unable to login"); } }
internal static void Main(string[] args) { Console.WriteLine("Please login in your dropbox account."); Console.WriteLine(new string('-', 30)); Console.Write("Press any key when ready"); Console.ReadLine(); Console.WriteLine(new string('-', 30)); var currentDir = Directory.GetCurrentDirectory(); var dirFiles = new DirectoryInfo(currentDir).Parent.Parent; var pictures = dirFiles.GetFiles("*.jpg"); var chosenPhotosIndexes = new List<int>(); PrintAndChoosePictures(pictures, chosenPhotosIndexes); DropNetClient client = new DropNetClient("0yfo5pqlswvwahb", "vi8gx0704m78ahy"); var token = client.GetToken(); var url = client.BuildAuthorizeUrl(); Clipboard.SetText(url); Console.WriteLine(new string('-', 30)); Console.WriteLine("App Url was copied to clipboard. Please paste it in your browser and click \"Allow\"."); Console.WriteLine(); Console.Write("Press any key when ready"); Console.ReadKey(true); var accessToken = client.GetAccessToken(); client.UserLogin.Secret = accessToken.Secret; client.UserLogin.Token = accessToken.Token; client.UseSandbox = true; Console.WriteLine(); Console.Write("Please enter an album name: "); var albumName = Console.ReadLine(); var folder = client.CreateFolder(albumName); Console.WriteLine(new string('-', 30)); Console.WriteLine("Uploading..."); foreach (var index in chosenPhotosIndexes) { MemoryStream sr = new MemoryStream((int)pictures[index].Length); FileStream fs = File.Open(pictures[index].FullName, FileMode.Open); var bytes = new byte[fs.Length]; fs.Read(bytes, 0, Convert.ToInt32(fs.Length)); client.UploadFile(folder.Path, pictures[index].Name, bytes); fs.Close(); } var shareUrl = client.GetShare(folder.Path); Clipboard.SetText(shareUrl.Url); Console.WriteLine("Url: {0}", shareUrl.Url); Console.WriteLine(); Console.WriteLine("Sharing Url copied to clipboard. Enjoy the cat pics!"); }