** Access to your personal Dropbox ** I recently wanted to download and upload files from my Dropbox. Turns out that this is easy to do in Tcl. If all you need is access to your own Dropbox, you don't have to implement the authorization process. Instead: 1. Go to https://www.dropbox.com/ and sign into your account. 1. Go to the "App Console" at https://www.dropbox.com/developers/apps 1. Click on "Create app". 11. Select "Dropbox API app" 11. Select "Files and datastores" 11. Select "No - My app needs access to files already on Dropbox" 11. Select "All file types -- My app needs access to a user's full Dropbox" 11. Provide an app name (for simplicity, just a random string) 1. After creating the app, find the "OAuth 2" section 1. Click on "Generate access token" 1. You will get the access token (a very long string) *** Prerequisites *** You need HTTP and TLS: package require http package require tls http::register https 443 ::tls::socket *** File Download *** To download a file, note its filename within your Dropbox root folder. Prefix it with "https://api-content.dropbox.com/1/files/auto". Here, I download the default file "How to use the Public folder.txt" from my Public directory. Note that the file name must be URL-encoded. set access_token "" set file "/Public/How%20to%20use%20the%20Public%20folder.txt" set base "https://api-content.dropbox.com/1/files/auto" set url "${base}${file}" set headers [list Host api-content.dropbox.com Authorization "Bearer $access_token"] Now just use the http command to download the file: set token [http::geturl $url -headers $headers] http::wait $token Get the file content with http::data $token. *** File Upload *** File upload is nearly as simple: set access_token "" set base "https://api-content.dropbox.com/1/files_put/auto" set url "${base}${file}" set content "" set contentLength [string length $content] set contentType "application/binary" set access_token "" set headers [list Content-Length $contentLength Host api-content.dropbox.com Authorization "Bearer $access_token"] set token [http::geturl $url -headers $headers -method PUT -type $contentType -query $content] http::wait $token