public DropboxTools()
        {
            try
            {
                // Variables
                DropboxClientConfig dropboxClientConfig;
                HttpClient          httpClient;
                Uri authURI;

                // Get authentication
                this.authState = Guid.NewGuid().ToString("N");
                authURI        = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, Global.AppKey, RedirectURI, state: this.authState);
                this.authURL   = authURI.AbsoluteUri.ToString();

                // Create dropbox client config
                dropboxClientConfig = new DropboxClientConfig(Global.AppName);

                // Create http client
                httpClient = new HttpClient
                {
                    Timeout = TimeSpan.FromMinutes(10)
                };

                // Create dropbox client
                dropboxClientConfig.HttpClient = httpClient;
                this.dropboxClient             = new DropboxClient(Global.AccessToken, dropboxClientConfig);
            }
            catch
            {
                // Error
            }
        }
Exemple #2
0
        /// <summary>
        /// This method is to generate Access Token required to access dropbox outside of the environment (in ANy application).
        /// </summary>
        /// <returns></returns>
        public string GenerateAccessToken()
        {
            try
            {
                string _strAccessToken = string.Empty;
                //this.AccessTocken = accessTocken;
                if (CanAuthenticate())
                {
                    if (string.IsNullOrEmpty(AuthenticationURL))
                    {
                        throw new Exception("AuthenticationURL is not generated !");
                    }

                    DropboxClientConfig CC  = new DropboxClientConfig(AppName, 1);
                    HttpClient          HTC = new HttpClient();
                    HTC.Timeout   = TimeSpan.FromMinutes(10); // set timeout for each ghttp request to Dropbox API.
                    CC.HttpClient = HTC;
                    DBClient      = new DropboxClient(AccessTocken, CC);
                }

                return(AccessTocken);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static DropboxClient SetupClient()
        {
            string accessToken = DropboxAuth.GetAccessToken();

            try
            {
                DropboxClientConfig config = new DropboxClientConfig();
                config.HttpClient = new HttpClient();

                return(new DropboxClient(accessToken, config));
            }
            catch (HttpException e)
            {
                string msg = "Exception reported from RPC layer";
                msg += string.Format("\n    Status code: {0}", e.StatusCode);
                msg += string.Format("\n    Message    : {0}", e.Message);
                if (e.RequestUri != null)
                {
                    msg += string.Format("\n    Request uri: {0}", e.RequestUri);
                }
                MessageBox.Show(msg);

                return(null);
            }
        }
Exemple #4
0
        /// <summary>
        /// *** This Function is used to get DropBox Client Object using Token
        /// *** Incase of error it set static variable MsgError with error details
        /// </summary>
        /// <param name="DropboxToken">Drop Box Token</param>
        /// <returns>Drop Box Client Object</returns>
        public static object getDropboxClient(string DropboxToken)
        {
            //*** Specify socket level timeout which decides maximum waiting time when on bytes are
            //*** received by the socket.
            var httpClient = new System.Net.Http.HttpClient(new System.Net.Http.WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                //*** Specify request level timeout which decides maximum time taht can be spent on
                //*** download/upload files.
                Timeout = TimeSpan.FromMinutes(20)
            };

            try
            {
                //*** Struct Config Class
                var config = new DropboxClientConfig("BasimAssignment")
                {
                    HttpClient = httpClient
                };

                //*** Get Client Object
                return(new DropboxClient(DropboxToken, config));
            }
            catch (Exception e) //*** Error
            {
                MsgError = e.ToString();

                return(null);
            }
        }
Exemple #5
0
        public DropBox(string loginAccessToken)
        {
            DropboxClientConfig config;
            HttpClient          httpClient;

            Dropbox.Api.Users.FullAccount userDropoBox;

            httpClient = new HttpClient(new WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                // Specify request level timeout which decides maximum time that can be spent on
                // download/upload files.
                Timeout = TimeSpan.FromMinutes(20)
            };


            config = new DropboxClientConfig()
            {
                HttpClient = httpClient
            };
            AccessToken  = loginAccessToken;
            client       = new Dropbox.Api.DropboxClient(AccessToken, config);
            userDropoBox = client.Users.GetCurrentAccountAsync().Result;


            User = new User(userDropoBox.Name.DisplayName, userDropoBox.Locale, userDropoBox.Email, userDropoBox.ProfilePhotoUrl, userDropoBox.EmailVerified);
        }
Exemple #6
0
        private void Initialize()
        {
            HttpClientHandler handler = new HttpClientHandler();

            if (Arg.ProxyState != 0)
            {
                handler.Proxy = new System.Net.WebProxy(Arg.ProxyHost, Arg.ProxyPort);
            }
            DropboxClientConfig config = new DropboxClientConfig("ConfDoctor");

            config.HttpClient = new HttpClient(handler);
            DropboxClient testClient = new DropboxClient(AccessToken, config);
            FullAccount   account    = null;

            try
            {
                account = testClient.Users.GetCurrentAccountAsync().Result;
                if (!account.Email.Equals(Arg.Email))
                {
                    IsInitialized = false;
                }
                else
                {
                    client        = testClient;
                    IsInitialized = true;
                }
            }
            catch (Exception e)
            {
                IsInitialized = false;
                System.Diagnostics.Debug.WriteLine(e.ToString());
            }
        }
Exemple #7
0
        /// <inheritdoc/>
        public async Task <bool> TryAuthenticateAsync()
        {
            var accessToken = GetAccessToken();

            if (string.IsNullOrWhiteSpace(accessToken))
            {
                IsAuthenticated = false;
                return(false);
            }

            var httpClient = new HttpClient
            {
                Timeout = TimeSpan.FromMinutes(20)
            };

            try
            {
                var config = new DropboxClientConfig(CoreHelper.GetApplicationName())
                {
                    HttpClient = httpClient
                };
                _client = new DropboxClient(SecurityHelper.ToUnsecureString(SecurityHelper.DecryptString(accessToken)), config);
                await _client.Users.GetCurrentAccountAsync();

                IsAuthenticated = true;
                Logger.Instance.Information($"User authenticated to {CloudServiceName}.");
            }
            catch (Exception exception)
            {
                Logger.Instance.Error(exception);
                IsAuthenticated = false;
            }

            return(IsAuthenticated);
        }
Exemple #8
0
        public static DropboxClient AuthenticatedClient(NetworkCredential credential)
        {
            var config = new DropboxClientConfig("KeeCloud")
            {
                HttpClient = httpClient
            };

            return(new DropboxClient(credential.Password, config));
        }
Exemple #9
0
        /// <summary>
        /// Récupère le Dbclient de dropbox
        /// </summary>
        /// <param name="AccessTocken"></param>
        public void GetDBClient(string AccessTocken)
        {
            DropboxClientConfig CC  = new DropboxClientConfig(AppName, 1);
            HttpClient          HTC = new HttpClient();

            HTC.Timeout   = TimeSpan.FromMinutes(10);
            CC.HttpClient = HTC;
            DBClient      = new DropboxClient(AccessTocken, CC);
        }
Exemple #10
0
        public void SetupFixture()
        {
            var config = new DropboxClientConfig();

            _dropboxClient  = new DropboxClient(_accessToken, config);
            _dropboxStorage = new DropboxStorage(_dropboxClient);

            UploadTestFile(_testFilePath);
        }
Exemple #11
0
        private void CreateClient(string apiToken)
        {
            var config = new DropboxClientConfig("PhotoMap")
            {
                HttpClient = HttpClient
            };

            _dropboxClient = new DropboxClient(apiToken, config);
        }
Exemple #12
0
        private static async Task <ListFolderResult> listFiles(string path)
        {
            ListFolderResult list = null;

            try
            {
                clientConf = new DropboxClientConfig("ScandaV1");
                client     = new DropboxClient(APITOKEN);
                list       = await client.Files.ListFolderAsync("/" + path);
            }
            catch (BadInputException ex)
            {
                Console.WriteLine("Error de Token");
                Console.WriteLine(ex.Message);
            }
            catch (ApiException <ListFolderError> ex)
            {
                //ApiException<ListFolderError>
                ListFolderError err = ex.ErrorResponse;
                if (err.IsPath)
                {
                    LookupError lerr = err.AsPath.Value;
                    if (lerr.IsMalformedPath)
                    {
                        Console.WriteLine("Ruta Mal Formateada");
                    }
                    if (lerr.IsNotFile)
                    {
                        Console.WriteLine("No es un archivo");
                    }
                    if (lerr.IsNotFolder)
                    {
                        Console.WriteLine("No es un Folder");
                    }
                    if (lerr.IsNotFound)
                    {
                        Console.WriteLine("Ruta no Hallada");
                    }
                    if (lerr.IsRestrictedContent)
                    {
                        Console.WriteLine("No tiene permisos");
                    }
                }
                else
                {
                    Console.WriteLine("Error No Indentificado");
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Fallo Desconocido");
            }


            return(list);
        }
Exemple #13
0
        public static DropboxClient GetApi(string accessToken)
        {
            var config = new DropboxClientConfig
            {
                HttpClient = ProxyTools.CreateHttpClient()
            };

            var api = new DropboxClient(accessToken, config);

            return api;
        }
Exemple #14
0
        private void init()
        {
            var accessToken = this.GetAccessToken();

            DropboxClientConfig CC  = new DropboxClientConfig(AppName, 3);
            HttpClient          HTC = new HttpClient();

            HTC.Timeout   = TimeSpan.FromMinutes(60 * 4);
            CC.HttpClient = HTC;
            DBClient      = new DropboxClient(accessToken, CC);
        }
        /// <summary>
        /// Re-init dropbox
        /// </summary>
        public static void ReloadDropbox()
        {
            DropboxClientConfig mConfig = new DropboxClientConfig(ApplicationName);

            mConfig.HttpClient                 = new System.Net.Http.HttpClient();
            mConfig.HttpClient.Timeout         = new TimeSpan(0, 0, 30);
            mConfig.LongPollHttpClient         = new System.Net.Http.HttpClient();
            mConfig.LongPollHttpClient.Timeout = new TimeSpan(0, 0, 30);

            dropboxClient = new DropboxClient(AccessToken, mConfig);
        }
        public static DropboxClient GetApi(string accessToken)
        {
            var config = new DropboxClientConfig
            {
                HttpClient = ProxyTools.CreateHttpClient()
            };

            var api = new DropboxClient(accessToken, config);

            return(api);
        }
        private async Task <int> Run()
        {
            DropboxCertHelper.InitializeCertPinning();

            var accessToken = await this.GetAccessToken();

            if (string.IsNullOrEmpty(accessToken))
            {
                return(1);
            }

            // Specify socket level timeout which decides maximum waiting time when no bytes are
            // received by the socket.
            var httpClient = new HttpClient(new WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                // Specify request level timeout which decides maximum time that can be spent on
                // download/upload files.
                Timeout = TimeSpan.FromMinutes(20)
            };

            try
            {
                var config = new DropboxClientConfig("SimpleTestApp")
                {
                    HttpClient = httpClient
                };

                var client = new DropboxClient(accessToken, config);
                await RunUserTests(client);

                // Tests below are for Dropbox Business endpoints. To run these tests, make sure the ApiKey is for
                // a Dropbox Business app and you have an admin account to log in.

                /*
                 * var client = new DropboxTeamClient(accessToken, userAgent: "SimpleTeamTestApp", httpClient: httpClient);
                 * await RunTeamTests(client);
                 */
            }
            catch (HttpException e)
            {
                Console.WriteLine("Exception reported from RPC layer");
                Console.WriteLine("    Status code: {0}", e.StatusCode);
                Console.WriteLine("    Message    : {0}", e.Message);
                if (e.RequestUri != null)
                {
                    Console.WriteLine("    Request uri: {0}", e.RequestUri);
                }
            }

            return(0);
        }
 public async Task<UserInfo> GetUserInfoAsync()
 {
     UserInfo user = new UserInfo();
     var config = new DropboxClientConfig() { HttpClient = client };
     using (var dbx = new DropboxClient(AccessToken, config))
     {
         var full = await dbx.Users.GetCurrentAccountAsync();
         user.Email = full.Email;
         user.Name = full.Name.DisplayName;
     }
     return user;
 }
        private DropboxClient GetDropboxClient()
        {
            var config = new DropboxClientConfig("Home_Assistant_Back")
            {
                HttpClient = new HttpClient()
                {
                    Timeout = TimeSpan.FromSeconds(_dropboxConfig.TimeoutSeconds)
                }
            };

            return(new DropboxClient(_secrets.DropboxToken, config));
        }
Exemple #20
0
        private static string downloadZipFile(string path, string folderName)
        {
            FileStream archivo = null;

            try
            {
                clientConf = new DropboxClientConfig("ScandaV1");
                client     = new DropboxClient(APITOKEN);
                path       = "/" + path;
                var x = client.Files.DownloadAsync(path);
                x.Wait();

                FileMetadata metadata = x.Result.Response;
                archivo = File.Create(metadata.Name);

                var y = x.Result.GetContentAsStreamAsync();
                y.Wait();

                Stream stream = y.Result;
                stream.CopyTo(archivo);

                archivo.Close();
                return(metadata.Name);
            }
            catch (OutOfMemoryException)
            {
                Console.WriteLine("Se acabo la memoria");
                return(null);
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("No existe el archivo");
                return(null);
            }
            catch (AggregateException ex) //Excepciones al vuelo
            {
                Console.WriteLine("Tarea Cancelada");
                return(null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
            finally
            {
                if (archivo != null)
                {
                    archivo.Close();
                    archivo.Dispose();
                }
            }
        }
Exemple #21
0
        public async Task <IActionResult> GetPhotoAsync(int id)
        {
            var photo = await _photoService.GetAsync(id);

            var user = await _userService.GetAsync(photo.UserId);

            var httpClient = new HttpClient();

            var config = new DropboxClientConfig("PhotoMap")
            {
                HttpClient = httpClient
            };
            var dropboxClient = new DropboxClient(user.DropboxAccessToken, config);

            var fileMetadata = await dropboxClient.Files.DownloadAsync(photo.Path);

            var fileContents = await fileMetadata.GetContentAsByteArrayAsync();

            if (photo.FileName.ToUpper().EndsWith("HEIC"))
            {
                var commandId           = Guid.NewGuid();
                var convertImageCommand = new ConvertImageEvent
                {
                    Id           = commandId,
                    FileContents = fileContents
                };

                _messageSender.Send(convertImageCommand);

                const int maxTimeout = 5000;
                int       waitTime   = 0;
                byte[]    convertedBytes;

                do
                {
                    await Task.Delay(1000);

                    convertedBytes = _convertedImageHolder.Get(commandId);
                    waitTime      += 1000;
                } while (waitTime <= maxTimeout || convertedBytes == null);

                if (convertedBytes != null)
                {
                    return(new FileContentResult(convertedBytes, "image/jpg"));
                }

                return(BadRequest());
            }

            return(new FileContentResult(fileContents, "image/jpg"));
        }
Exemple #22
0
        private async Task <int> Run()
        {
            DropboxCertHelper.InitializeCertPinning();

            var uid = await this.AcquireAccessToken(null, IncludeGrantedScopes.None);

            if (string.IsNullOrEmpty(uid))
            {
                return(1);
            }

            // Specify socket level timeout which decides maximum waiting time when no bytes are
            // received by the socket.
            var httpClient = new HttpClient(new WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                // Specify request level timeout which decides maximum time that can be spent on
                // download/upload files.
                Timeout = TimeSpan.FromMinutes(20)
            };

            try
            {
                var config = new DropboxClientConfig("SimplePKCEOAuthApp")
                {
                    HttpClient = httpClient
                };

                var client = new DropboxClient(Settings.Default.RefreshToken, ApiKey, config);

                // This call should succeed since the correct scope has been acquired
                await GetCurrentAccount(client);

                Console.WriteLine("Oauth PKCE Test Complete!");
                Console.WriteLine("Exit with any key");
                Console.ReadKey();
            }
            catch (HttpException e)
            {
                Console.WriteLine("Exception reported from RPC layer");
                Console.WriteLine("    Status code: {0}", e.StatusCode);
                Console.WriteLine("    Message    : {0}", e.Message);
                if (e.RequestUri != null)
                {
                    Console.WriteLine("    Request uri: {0}", e.RequestUri);
                }
            }

            return(0);
        }
Exemple #23
0
        public DropboxClient GenerateClient()
        {
            var httpClient = new HttpClient()
            {
                Timeout = TimeSpan.FromMinutes(20),
            };

            var conf = new DropboxClientConfig(DropBoxConfig.Instance.AppName)
            {
                HttpClient = httpClient
            };

            return(new DropboxClient(AccessToken, conf));
        }
        private static DropboxClient GetClient(string accessToken)
        {
            var httpClient = new HttpClient(new HttpClientHandler())
            {
                Timeout = TimeSpan.FromMinutes(20)
            };

            var configuration = new DropboxClientConfig("DropboxUploader")
            {
                HttpClient = httpClient
            };

            return(new DropboxClient(accessToken, configuration));
        }
Exemple #25
0
        private void webBrowser_Navigating(object sender, System.Windows.Navigation.NavigatingCancelEventArgs e)
        {
            try
            {
                this.Result = false;

                #region Dropbox

                if (AuthType == AuthenticateTypeList.Dropbox)
                {
                    if (!e.Uri.ToString().StartsWith(db_RedirectUri, StringComparison.OrdinalIgnoreCase))
                    {
                        return;
                    }

                    OAuth2Response result = DropboxOAuth2Helper.ParseTokenFragment(e.Uri);
                    if (result.State != this.db_Oauth2State)
                    {
                        return;
                    }

                    this.db_AccessToken = result.AccessToken;
                    this.db_UserId      = result.Uid;
                    this.Result         = true;

                    var httpClient = new HttpClient()
                    {
                        Timeout = TimeSpan.FromMinutes(20)
                    };

                    var config = new DropboxClientConfig("SimpleTestApp")
                    {
                        HttpClient = httpClient
                    };

                    db_Client = new DropboxClient(this.db_AccessToken, config);

                    this.Close();
                }

                #endregion Dropbox
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                this.Result = false;
                this.Close();
            }
        }
Exemple #26
0
 /// <summary>
 /// This method is to generate Access Token required to access dropbox outside of the environment (in ANy application).
 /// </summary>
 /// <returns></returns>
 public void GenerateAccessToken() //=> "p5L439MIDIkAAAAAAAAHDP6DYNaCltCpGwTpXIjW_RXOpKoSpi4fIOXxjpjKbrDJ";
 {
     try
     {
         DropboxClientConfig CC  = new DropboxClientConfig(AppName, 1);
         HttpClient          HTC = new HttpClient();
         HTC.Timeout   = TimeSpan.FromMinutes(10); // set timeout for each ghttp request to Dropbox API.
         CC.HttpClient = HTC;
         DBClient      = new DropboxClient(AccessToken, CC);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #27
0
        public bool FinishFromUri(Uri uri)
        {
            try
            {
                string   url = uri.ToString();
                string[] param = url.Substring(url.IndexOf('?') + 1).Split('&');
                string   state, code;
                if (param[0].StartsWith("state"))
                {
                    state = param[0].Substring(param[0].IndexOf('=') + 1);
                    code  = param[1].Substring(param[1].IndexOf('=') + 1);
                }
                else
                {
                    code  = param[0].Substring(param[0].IndexOf('=') + 1);
                    state = param[1].Substring(param[1].IndexOf('=') + 1);
                }

                if (state != oauth2State)
                {
                    return(false);
                }

                HttpClientHandler handler = new HttpClientHandler();
                if (Arg.ProxyState != 0)
                {
                    handler.Proxy = new System.Net.WebProxy(Arg.ProxyHost, Arg.ProxyPort);
                }
                OAuth2Response result = DropboxOAuth2Helper.ProcessCodeFlowAsync(code, App_key, App_secret, RedirectUri, new HttpClient(handler)).Result;

                this.AccessToken = result.AccessToken;
                Arg.AccessToken  = result.AccessToken;
                this.Uid         = result.Uid;

                DropboxClientConfig config = new DropboxClientConfig("ConfDoctor");
                config.HttpClient = new HttpClient(handler);
                client            = new DropboxClient(AccessToken, config);

                FullAccount account = client.Users.GetCurrentAccountAsync().Result;
                Arg.UserName = account.Name.DisplayName;

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public async Task <UserInfo> GetUserInfoAsync()
        {
            UserInfo user   = new UserInfo();
            var      config = new DropboxClientConfig()
            {
                HttpClient = client
            };

            using (var dbx = new DropboxClient(AccessToken, config))
            {
                var full = await dbx.Users.GetCurrentAccountAsync();

                user.Email = full.Email;
                user.Name  = full.Name.DisplayName;
            }
            return(user);
        }
        public DropboxClient GetInstance()
        {
            var httpClient = new HttpClient(new WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                Timeout = TimeSpan.FromMinutes(20)
            };

            var dropboxClientConfig = new DropboxClientConfig("VirgilSync")
            {
                HttpClient        = httpClient,
                MaxRetriesOnError = 3
            };

            return(new DropboxClient(this.accessToken, dropboxClientConfig));
        }
Exemple #30
0
        public DropBoxProvider(string accessToken, string baseFolder)
        {
            var httpClient = new HttpClient()
            {
                Timeout = TimeSpan.FromMinutes(20)
            };
            var config = new DropboxClientConfig("SimpleTestApp")
            {
                HttpClient = httpClient
            };

            _client = new DropboxClient(accessToken, config);

            FolderMetadata folder = CreateFolder(baseFolder).Result;

            _baseFolder = baseFolder;
        }
        private async Task LoginToDropBoxAsync()
        {
            DropboxCertHelper.InitializeCertPinning();

            //String accessToken = await GetAccessToken();
            String accessToken = await GetAccessToken();

            if (accessToken == null || accessToken.Length == 0)
            {
                return;
            }

            var httpClient = new HttpClient(new WebRequestHandler {
                ReadWriteTimeout = 10 * 1000
            })
            {
                Timeout = TimeSpan.FromMinutes(1)
            };

            var config = new DropboxClientConfig("SampleApp")
            {
                HttpClient = httpClient
            };

            var client = new DropboxClient(accessToken, config);

            //var full = Task.Run( async ()=> await client.Users.GetCurrentAccountAsync(), token).Result;
            var full = await client.Users.GetCurrentAccountAsync();

            Console.WriteLine("Account id    : {0}", full.AccountId);
            Console.WriteLine("Country       : {0}", full.Country);
            Console.WriteLine("Email         : {0}", full.Email);
            Console.WriteLine("Is paired     : {0}", full.IsPaired ? "Yes" : "No");
            Console.WriteLine("Locale        : {0}", full.Locale);
            Console.WriteLine("Name");
            Console.WriteLine("  Display  : {0}", full.Name.DisplayName);
            Console.WriteLine("  Familiar : {0}", full.Name.FamiliarName);
            Console.WriteLine("  Given    : {0}", full.Name.GivenName);
            Console.WriteLine("  Surname  : {0}", full.Name.Surname);
            Console.WriteLine("  Photo  : {0}", full.ProfilePhotoUrl);


            //invoke Update main UI in Block 2
            Dispatcher.Invoke(new Action <Dropbox.Api.Users.FullAccount>(UpdateAccountInfoBlockHandler), full);
        }
        public string GenerateAccessToken()
        {
            try {
                string _accessToken = string.Empty;

                if (CanAuthenticate())
                {
                    if (string.IsNullOrEmpty(AuthenticationURL))
                    {
                        throw new Exception("Authentication URL is not generated!");
                    }

                    DropBoxLogin dropBoxLogin = new DropBoxLogin(AppKey, AuthenticationURL, this.OAuth2State);
                    dropBoxLogin.Owner = DropBoxMain.ActiveForm;
                    dropBoxLogin.ShowDialog();
                    if (dropBoxLogin.Result)
                    {
                        _accessToken = dropBoxLogin.AccessToken;
                        AccessToken  = dropBoxLogin.AccessToken;
                        UID          = dropBoxLogin.Uid;
                        DropboxClientConfig _clientConfig = new DropboxClientConfig(AppKey, 1);
                        HttpClient          httpClient    = new HttpClient();
                        httpClient.Timeout       = TimeSpan.FromMinutes(10);
                        _clientConfig.HttpClient = httpClient;
                        _client = new DropboxClient(AccessToken, _clientConfig);

                        string _crypto = Crypto.Encrypt(_accessToken);
                        File.Save(_crypto, "ConfigDB.data");
                    }
                    else
                    {
                        _client     = null;
                        AccessToken = string.Empty;
                        UID         = string.Empty;
                    }
                }


                return(_accessToken);
            }catch (Exception e) {
                throw e;
            }
        }