Пример #1
0
        public DropboxFilesForm(OAuthInfo oauth, string path, DropboxAccountInfo accountInfo)
        {
            InitializeComponent();
            Icon = Resources.Dropbox;

            dropbox = new Dropbox(oauth);
            dropboxAccountInfo = accountInfo;
            ilm = new ImageListManager(lvDropboxFiles);

            if (path != null)
            {
                Shown += (sender, e) => OpenDirectory(path);
            }
        }
Пример #2
0
        /* OAuth 1.0
         * // https://www.dropbox.com/developers/core/docs#request-token
         * // https://www.dropbox.com/developers/core/docs#authorize
         * public string GetAuthorizationURL()
         * {
         *  return GetAuthorizationURL(URLAPI + "/oauth/request_token", URLWEB + "/oauth/authorize", AuthInfo);
         * }
         *
         * // https://www.dropbox.com/developers/core/docs#access-token
         * public bool GetAccessToken(string verificationCode = null)
         * {
         *  AuthInfo.AuthVerifier = verificationCode;
         *  return GetAccessToken(URLAPI + "/oauth/access_token", AuthInfo);
         * }
         */

        #region Dropbox accounts

        // https://www.dropbox.com/developers/core/docs#account-info
        public DropboxAccountInfo GetAccountInfo()
        {
            DropboxAccountInfo account = null;

            if (OAuth2Info.CheckOAuth(AuthInfo))
            {
                string response = SendRequest(HttpMethod.GET, URLAccountInfo, headers: GetAuthHeaders());

                if (!string.IsNullOrEmpty(response))
                {
                    account = JsonConvert.DeserializeObject <DropboxAccountInfo>(response);

                    if (account != null)
                    {
                        AccountInfo = account;
                    }
                }
            }

            return(account);
        }
        /// <summary>Retrieves information about the user's account.</summary>
        /// <returns>User account information.</returns>
        public DropboxAccountInfo GetAccountInfo()
        {
            if (OAuthInfo.CheckOAuth(AuthInfo))
            {
                string url = OAuthManager.GenerateQuery(URLAccountInfo, null, HttpMethod.Get, AuthInfo);

                string response = SendGetRequest(url);

                if (!string.IsNullOrEmpty(response))
                {
                    DropboxAccountInfo account = JsonConvert.DeserializeObject <DropboxAccountInfo>(response);

                    if (account != null)
                    {
                        AccountInfo = account;
                        return(account);
                    }
                }
            }

            return(null);
        }
Пример #4
0
 public Dropbox(OAuthInfo oauth, string uploadPath, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     UploadPath = uploadPath;
     AccountInfo = accountInfo;
 }
Пример #5
0
 public Dropbox(OAuthInfo oauth, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     AccountInfo = accountInfo;
 }
Пример #6
0
 public Dropbox(OAuth2Info oauth, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     AccountInfo = accountInfo;
 }
 public Dropbox(OAuthInfo oauth, string uploadPath, DropboxAccountInfo accountInfo)
     : this(oauth)
 {
     UploadPath  = uploadPath;
     AccountInfo = accountInfo;
 }