Example #1
0
        async void Initialize()
        {
            var keys = new KeyStorage();
            var client = new DropNetClient(await keys.Get("dropbox-apikey"), await keys.Get("dropbox-secret"));
            client.UseSandbox = true;

            var token = await client.GetRequestToken();
            var url = client.BuildAuthorizeUrl(token, "http://localhost");

            var regClient = new WebClientImpl();
            browser.SetWebViewClient(regClient);
            browser.LoadUrl(url);

            await regClient.Callback.Task;
            await client.GetAccessToken();

            browser.Visibility = ViewStates.Gone;

            var items = new List<Adaptar.Item>();
            foreach (var file in (await client.GetMetaData("/")).Contents.Take(10))
            {
                var buffer = await client.GetThumbnail(file);
                items.Add(
                    new Adaptar.Item
                    {
                        Title = file.Name,
                        Icon = await BitmapFactory.DecodeByteArrayAsync(buffer, 0, buffer.Length),
                    });
            }
            adapter.Update(items);
        }
        public async void AskUserForPermission(IExternalBrowserService externalBrowserService)
        {
            _client = new DropNetClient(AppKey, AppSecret);
            var token = await _client.GetRequestToken();
            var url = _client.BuildAuthorizeUrl(token);

            externalBrowserService.OpenUrl(url);
        }
        public async Task Given_A_Clent_Get_User_Account_Infromation()
        {
            var client = new DropNetClient(AppKey, AppSecret, UserToken, UserSecret);
            var accountInfromation = await client.AccountInfo();

            Assert.NotNull(accountInfromation);
            Assert.NotNull(accountInfromation.QuotaInfo);
        }
        public async Task Given_UserToken_When_Build_Auth_Url_Then_The_Authentication_Url_Is_Returned()
        {
            var client = new DropNetClient(AppKey, AppSecret);

            var userToken = await client.GetRequestToken();
            string url = client.BuildAuthorizeUrl(userToken, "http://cloudyboxapp.com");
            Assert.IsNotEmpty(url);
        }
 public DropboxProvider(CloudToken token)
 {
     client = new DropNetClient(apiKey: API_KEY, appSecret: APP_SECRET);
     client.UseSandbox = true;
     if (token.Secret != string.Empty || token.Token != string.Empty)
     {
         var accessToken = new UserLogin { Secret = token.Secret, Token = token.Token };
         client.SetUserToken(accessToken);
     }
 }
 public DropboxAccessViewModel(INavigationService navigationService,
     ICache cache,
     IDialogService dialogService)
 {
     _dialogService = dialogService;
     _cache = cache;
     _navigationService = navigationService;
     _client = new DropNetClient(
         ApiKeys.DropBoxKey, ApiKeys.DropBoxSecret);
     _navigationService.Navigated += _navigationService_Navigated;
 }
        public async Task Get_Access_Token_Test()
        {
            var client = new DropNetClient(AppKey, AppSecret);

            var userToken = await client.GetRequestToken();
            
            //Open the url in browser and login
            string url = client.BuildAuthorizeUrl(userToken, "http://cloudyboxapp.com");
            var user = await client.GetAccessToken();

            Assert.NotNull(user);
        }
Example #8
0
 public async Task Activate()
 {
     if(string.IsNullOrEmpty(_cache.DropboxUserSecret) || string.IsNullOrEmpty(_cache.DropboxUserToken))
     {
         _client = new DropNetClient(ApiKeys.DropBoxKey,
             ApiKeys.DropBoxSecret);
         var tokens = await _client.GetAccessToken();
         _cache.DropboxUserSecret = tokens.Secret;
         _cache.DropboxUserToken = tokens.Token;
     }
     else
     {
         _client = new DropNetClient(
        ApiKeys.DropBoxKey,
        ApiKeys.DropBoxSecret,
        _cache.DropboxUserToken,
        _cache.DropboxUserSecret);              
     }
     _client.UseSandbox = true;
 }
Example #9
0
        private static async Task Upload(string source, string filename, UploadOptions options, DropNetClient client,
            CancellationToken cancellationToken)
        {
            Output($"Uploading {filename} to {options.DropboxPath}", options);
            Console.Title = $"Uploading {filename} to {options.DropboxPath}";

            if(ShowCancelHelp)
            {
                Output("Ctrl-C to cancel", options);
                ShowCancelHelp = false;
            }

            using(var fs = new FileStream(source, FileMode.Open, FileAccess.Read))
            {
                Metadata uploaded;

                if(options.Chunked)
                {
                    var progress = ConfigureProgressHandler(options, fs.Length);

                    if(!options.Chunked && fs.Length >= 150*1024*1024)
                    {
                        Output("File is larger than 150MB, using chunked uploading.", options);
                        options.Chunked = true;
                    }

                    uploaded = await client.UploadChunked(options.DropboxPath, filename, fs, cancellationToken, progress);
                }
                else
                {
                    uploaded = await client.Upload(options.DropboxPath, filename, fs, cancellationToken);
                }

                Output("Whoosh...", options);
                Output($"Uploaded {uploaded.Name} to {uploaded.Path}; Revision {uploaded.Revision}", options);
            }
        }
Example #10
0
        private static async Task Upload(IEnumerable<string> paths, UploadOptions options, DropNetClient client,
            CancellationToken cancellationToken)
        {
            foreach(var path in paths)
            {
                var source = Path.GetFullPath(path);
                var filename = Path.GetFileName(source);

                await Upload(source, filename, options, client, cancellationToken);
            }
        }
 public DropboxConnection(UserLogin userLogin)
 {
     _dropboxClient = DropboxUserPermission.GetAuthenticatedClient(userLogin);
 }
Example #12
0
 public void Setup()
 {
     _client = new DropNetClient(AppKey, AppSecret, UserToken, UserSecret);
 }
Example #13
0
 public async Task When_Token_Requested_Then_User_Token_Is_Returned()
 {   
     var client = new DropNetClient(AppKey, AppSecret);
     var userToken = await client.GetRequestToken();
     Assert.NotNull(userToken);
 }