[{"data":1,"prerenderedAt":2241},["ShallowReactive",2],{"writing-2024-03-14-upload-files-to-dropbox-using-python":3,"writing-surroundings-2024-03-14-upload-files-to-dropbox-using-python":2235},{"id":4,"title":5,"body":6,"date":2221,"description":2222,"draft":2223,"extension":2224,"image":67,"meta":2225,"navigation":214,"path":2226,"seo":2227,"stem":2228,"tags":2229,"updated":2233,"__hash__":2234},"writing\u002Fwriting\u002F2024-03-14-upload-files-to-dropbox-using-python.md","Upload Files to Dropbox using Python",{"type":7,"value":8,"toc":2211},"minimark",[9,22,27,30,48,52,60,69,76,91,97,103,109,113,116,182,186,193,285,294,300,312,318,324,332,340,344,350,630,640,644,656,659,667,670,674,680,683,715,728,749,752,760,764,767,2174,2177,2189,2193,2196,2199,2207],[10,11,12,13,17,18,21],"p",{},"Do you spend time manually uploading files to ",[14,15,16],"strong",{},"Dropbox","? Take control with ",[14,19,20],{},"Python","! In this article, I'll share my Python program that simplifies file uploads to Dropbox.",[23,24,26],"h2",{"id":25},"prerequisites","Prerequisites",[10,28,29],{},"Before we dive into the Python script, make sure you have the following:",[31,32,33,37],"ol",{},[34,35,36],"li",{},"A Dropbox account",[34,38,39,40,47],{},"Python installed on your machine: Download and install Python from ",[41,42,46],"a",{"href":43,"rel":44},"https:\u002F\u002Fwww.python.org\u002F",[45],"nofollow","python.org",".",[23,49,51],{"id":50},"create-an-app-on-dropbox","Create an App on Dropbox",[10,53,54,55,47],{},"To create an app on Dropbox, go to ",[41,56,59],{"href":57,"rel":58},"https:\u002F\u002Fwww.dropbox.com\u002Fdevelopers\u002Fapps",[45],"Dropbox Developer Apps",[10,61,62],{},[63,64],"img",{"alt":65,"height":66,"src":67,"width":68},"The Dropbox developer apps console, where you create a new app",992,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F01-dropbox-developer-apps.png",1920,[10,70,71],{},[63,72],{"alt":73,"height":74,"src":75,"width":68},"Choosing the Scoped Access API and app folder access when creating the app",993,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F02-create-app-form.png",[10,77,78,79,82,83,86,87,90],{},"After creating an app you have an ",[14,80,81],{},"App key",", ",[14,84,85],{},"App secret"," please keep it secret, and generate ",[14,88,89],{},"Access Token"," by clicking on the Generate button.",[10,92,93],{},[63,94],{"alt":95,"height":66,"src":96,"width":68},"The app settings page showing the App key, App secret, and the Generate access token button","\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F03-app-key-secret-access-token.png",[10,98,99,100,102],{},"After generating ",[14,101,89],{}," now go to permissions section and set the required permissions.",[10,104,105],{},[63,106],{"alt":107,"height":66,"src":108,"width":68},"The Permissions tab, where the required scopes are enabled for the app","\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F04-app-permissions.png",[23,110,112],{"id":111},"setting-up-the-project","Setting Up the Project",[10,114,115],{},"To get started, create a new Python script and install the necessary packages. Open your terminal or command prompt and run the following commands:",[117,118,123],"pre",{"className":119,"code":120,"language":121,"meta":122,"style":122},"language-bash shiki shiki-themes min-light min-dark","pip install dropbox\npip install requests\npip install configparser\npip install pybase64\npip install jsonlib\n","bash","",[124,125,126,142,152,162,172],"code",{"__ignoreMap":122},[127,128,131,135,139],"span",{"class":129,"line":130},"line",1,[127,132,134],{"class":133},"sScJk","pip",[127,136,138],{"class":137},"sXSfg"," install",[127,140,141],{"class":137}," dropbox\n",[127,143,145,147,149],{"class":129,"line":144},2,[127,146,134],{"class":133},[127,148,138],{"class":137},[127,150,151],{"class":137}," requests\n",[127,153,155,157,159],{"class":129,"line":154},3,[127,156,134],{"class":133},[127,158,138],{"class":137},[127,160,161],{"class":137}," configparser\n",[127,163,165,167,169],{"class":129,"line":164},4,[127,166,134],{"class":133},[127,168,138],{"class":137},[127,170,171],{"class":137}," pybase64\n",[127,173,175,177,179],{"class":129,"line":174},5,[127,176,134],{"class":133},[127,178,138],{"class":137},[127,180,181],{"class":137}," jsonlib\n",[23,183,185],{"id":184},"obtaining-access-code","Obtaining Access Code",[10,187,188,189,192],{},"Open your preferred text editor and create a new Python file. You can name it ",[14,190,191],{},"get_access_code.py",". Now copy the following code into your Python script file",[117,194,198],{"className":195,"code":196,"language":197,"meta":122,"style":122},"language-python shiki shiki-themes min-light min-dark","import webbrowser\n\nAPP_KEY = '\u003CAPP_KEY>'\nurl = f'https:\u002F\u002Fwww.dropbox.com\u002Foauth2\u002Fauthorize?client_id={APP_KEY}&' \\\n      f'response_type=code&token_access_type=offline'\n\nwebbrowser.open(url)\n","python",[124,199,200,210,216,228,258,266,271],{"__ignoreMap":122},[127,201,202,206],{"class":129,"line":130},[127,203,205],{"class":204},"se1w0","import",[127,207,209],{"class":208},"sHHeI"," webbrowser\n",[127,211,212],{"class":129,"line":144},[127,213,215],{"emptyLinePlaceholder":214},true,"\n",[127,217,218,221,224],{"class":129,"line":154},[127,219,220],{"class":208},"APP_KEY ",[127,222,223],{"class":204},"=",[127,225,227],{"class":226},"sxIrz"," '\u003CAPP_KEY>'\n",[127,229,230,233,235,238,241,245,248,251,254],{"class":129,"line":164},[127,231,232],{"class":208},"url ",[127,234,223],{"class":204},[127,236,237],{"class":204}," f",[127,239,240],{"class":226},"'https:\u002F\u002Fwww.dropbox.com\u002Foauth2\u002Fauthorize?client_id=",[127,242,244],{"class":243},"soJJD","{",[127,246,247],{"class":208},"APP_KEY",[127,249,250],{"class":243},"}",[127,252,253],{"class":226},"&'",[127,255,257],{"class":256},"som3e"," \\\n",[127,259,260,263],{"class":129,"line":174},[127,261,262],{"class":204},"      f",[127,264,265],{"class":226},"'response_type=code&token_access_type=offline'\n",[127,267,269],{"class":129,"line":268},6,[127,270,215],{"emptyLinePlaceholder":214},[127,272,274,277,279,282],{"class":129,"line":273},7,[127,275,276],{"class":208},"webbrowser",[127,278,47],{"class":256},[127,280,281],{"class":133},"open",[127,283,284],{"class":256},"(url)\n",[10,286,287,288,290,291,293],{},"Replace ",[14,289,247],{}," with your Dropbox ",[14,292,81],{},". This code will open a browser window prompting you to log in to your Dropbox account and authorize access for your app. After authorization, Dropbox will redirect you to a URL containing the access code.",[10,295,296,299],{},[14,297,298],{},"Run the Script:"," Save the Python script and execute it by running the following command in your terminal or command prompt:",[117,301,303],{"className":119,"code":302,"language":121,"meta":122,"style":122},"python get_access_code.py\n",[124,304,305],{"__ignoreMap":122},[127,306,307,309],{"class":129,"line":130},[127,308,197],{"class":133},[127,310,311],{"class":137}," get_access_code.py\n",[10,313,314,317],{},[14,315,316],{},"Authorize Dropbox Access:"," Follow the prompts in your browser to log in to your Dropbox account and authorize access for your app. Once authorized, you will be redirected to a page displaying the access code.",[10,319,320,323],{},[14,321,322],{},"Copy the Access Code:"," Copy the access code from the browser window. We'll use this access code in our Python script to authenticate with Dropbox's API.",[10,325,326],{},[63,327],{"alt":328,"height":329,"src":330,"width":331},"The Dropbox confirmation screen shown before you connect the app",732,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F05-authorize-app.png",1085,[10,333,334],{},[63,335],{"alt":336,"height":337,"src":338,"width":339},"The generated access code, ready to be copied",432,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F06-access-code.png",1007,[23,341,343],{"id":342},"obtaining-refresh-token","Obtaining Refresh Token",[10,345,188,346,349],{},[14,347,348],{},"get_refresh_token.py",". Copy the following code into your Python script file:",[117,351,353],{"className":195,"code":352,"language":197,"meta":122,"style":122},"import base64\nimport requests\nimport json\n\nAPP_KEY = '\u003CAPP_KEY>'\nAPP_SECRET = '\u003CAPP_SECRET>'\nACCESS_CODE_GENERATED = '\u003CACCESS_CODE_GENERATED>'\n\nBASIC_AUTH = base64.b64encode(f'{APP_KEY}:{APP_SECRET}'.encode())\n\nheaders = {\n    'Authorization': f\"Basic {BASIC_AUTH}\",\n    'Content-Type': 'application\u002Fx-www-form-urlencoded',\n}\n\ndata = f'code={ACCESS_CODE_GENERATED}&grant_type=authorization_code'\n\nresponse = requests.post('https:\u002F\u002Fapi.dropboxapi.com\u002Foauth2\u002Ftoken',\n                         data=data,\n                         auth=(APP_KEY, APP_SECRET))\nprint(json.dumps(json.loads(response.text), indent=2))\n",[124,354,355,362,368,375,379,387,397,407,412,463,468,479,505,518,524,529,552,557,580,591,602],{"__ignoreMap":122},[127,356,357,359],{"class":129,"line":130},[127,358,205],{"class":204},[127,360,361],{"class":208}," base64\n",[127,363,364,366],{"class":129,"line":144},[127,365,205],{"class":204},[127,367,151],{"class":208},[127,369,370,372],{"class":129,"line":154},[127,371,205],{"class":204},[127,373,374],{"class":208}," json\n",[127,376,377],{"class":129,"line":164},[127,378,215],{"emptyLinePlaceholder":214},[127,380,381,383,385],{"class":129,"line":174},[127,382,220],{"class":208},[127,384,223],{"class":204},[127,386,227],{"class":226},[127,388,389,392,394],{"class":129,"line":268},[127,390,391],{"class":208},"APP_SECRET ",[127,393,223],{"class":204},[127,395,396],{"class":226}," '\u003CAPP_SECRET>'\n",[127,398,399,402,404],{"class":129,"line":273},[127,400,401],{"class":208},"ACCESS_CODE_GENERATED ",[127,403,223],{"class":204},[127,405,406],{"class":226}," '\u003CACCESS_CODE_GENERATED>'\n",[127,408,410],{"class":129,"line":409},8,[127,411,215],{"emptyLinePlaceholder":214},[127,413,415,418,420,423,425,428,431,434,437,439,441,443,446,448,451,453,455,457,460],{"class":129,"line":414},9,[127,416,417],{"class":208},"BASIC_AUTH ",[127,419,223],{"class":204},[127,421,422],{"class":208}," base64",[127,424,47],{"class":256},[127,426,427],{"class":133},"b64encode",[127,429,430],{"class":256},"(",[127,432,433],{"class":204},"f",[127,435,436],{"class":226},"'",[127,438,244],{"class":243},[127,440,247],{"class":256},[127,442,250],{"class":243},[127,444,445],{"class":226},":",[127,447,244],{"class":243},[127,449,450],{"class":256},"APP_SECRET",[127,452,250],{"class":243},[127,454,436],{"class":226},[127,456,47],{"class":256},[127,458,459],{"class":133},"encode",[127,461,462],{"class":256},"())\n",[127,464,466],{"class":129,"line":465},10,[127,467,215],{"emptyLinePlaceholder":214},[127,469,471,474,476],{"class":129,"line":470},11,[127,472,473],{"class":208},"headers ",[127,475,223],{"class":204},[127,477,478],{"class":256}," {\n",[127,480,482,485,487,489,492,494,497,499,502],{"class":129,"line":481},12,[127,483,484],{"class":226},"    'Authorization'",[127,486,445],{"class":256},[127,488,237],{"class":204},[127,490,491],{"class":226},"\"Basic ",[127,493,244],{"class":243},[127,495,496],{"class":208},"BASIC_AUTH",[127,498,250],{"class":243},[127,500,501],{"class":226},"\"",[127,503,504],{"class":256},",\n",[127,506,508,511,513,516],{"class":129,"line":507},13,[127,509,510],{"class":226},"    'Content-Type'",[127,512,445],{"class":256},[127,514,515],{"class":226}," 'application\u002Fx-www-form-urlencoded'",[127,517,504],{"class":256},[127,519,521],{"class":129,"line":520},14,[127,522,523],{"class":256},"}\n",[127,525,527],{"class":129,"line":526},15,[127,528,215],{"emptyLinePlaceholder":214},[127,530,532,535,537,539,542,544,547,549],{"class":129,"line":531},16,[127,533,534],{"class":208},"data ",[127,536,223],{"class":204},[127,538,237],{"class":204},[127,540,541],{"class":226},"'code=",[127,543,244],{"class":243},[127,545,546],{"class":208},"ACCESS_CODE_GENERATED",[127,548,250],{"class":243},[127,550,551],{"class":226},"&grant_type=authorization_code'\n",[127,553,555],{"class":129,"line":554},17,[127,556,215],{"emptyLinePlaceholder":214},[127,558,560,563,565,568,570,573,575,578],{"class":129,"line":559},18,[127,561,562],{"class":208},"response ",[127,564,223],{"class":204},[127,566,567],{"class":208}," requests",[127,569,47],{"class":256},[127,571,572],{"class":133},"post",[127,574,430],{"class":256},[127,576,577],{"class":226},"'https:\u002F\u002Fapi.dropboxapi.com\u002Foauth2\u002Ftoken'",[127,579,504],{"class":256},[127,581,583,586,588],{"class":129,"line":582},19,[127,584,585],{"class":256},"                         data",[127,587,223],{"class":204},[127,589,590],{"class":256},"data,\n",[127,592,594,597,599],{"class":129,"line":593},20,[127,595,596],{"class":256},"                         auth",[127,598,223],{"class":204},[127,600,601],{"class":256},"(APP_KEY, APP_SECRET))\n",[127,603,605,608,611,614,616,619,622,624,627],{"class":129,"line":604},21,[127,606,607],{"class":133},"print",[127,609,610],{"class":256},"(json.",[127,612,613],{"class":133},"dumps",[127,615,610],{"class":256},[127,617,618],{"class":133},"loads",[127,620,621],{"class":256},"(response.text), indent",[127,623,223],{"class":204},[127,625,626],{"class":243},"2",[127,628,629],{"class":256},"))\n",[10,631,287,632,82,634,636,637,639],{},[14,633,247],{},[14,635,450],{},", and ",[14,638,546],{}," with your Dropbox app key, app secret, and the access code obtained in the previous step.",[10,641,642,299],{},[14,643,298],{},[117,645,647],{"className":119,"code":646,"language":121,"meta":122,"style":122},"python get_refresh_token.py\n",[124,648,649],{"__ignoreMap":122},[127,650,651,653],{"class":129,"line":130},[127,652,197],{"class":133},[127,654,655],{"class":137}," get_refresh_token.py\n",[10,657,658],{},"the output is",[10,660,661],{},[63,662],{"alt":663,"height":664,"src":665,"width":666},"The token endpoint response, containing the access token and the long-lived refresh token",147,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F07-refresh-token-output.png",730,[10,668,669],{},"With the refresh token obtained, we can now proceed to integrate it into our Python script for uploading files to Dropbox.",[23,671,673],{"id":672},"creating-credentials-configuration-file","Creating Credentials Configuration File",[10,675,676,677,47],{},"To securely store your Dropbox app's credentials and tokens, we'll create a configuration file named ",[14,678,679],{},"credentials.ini",[10,681,682],{},"Open your preferred text editor and create a new file named credentials.ini. Copy the following content into the credentials.ini file:",[117,684,688],{"className":685,"code":686,"language":687,"meta":122,"style":122},"language-ini shiki shiki-themes min-light min-dark","[Authentication]\naccess_token = \u003CACCESS_TOKEN>\napp_key = \u003CAPP_KEY>\napp_secret = \u003CAPP_SECRET>\nrefresh_token = \u003CREFRESH_TOKEN>\n","ini",[124,689,690,695,700,705,710],{"__ignoreMap":122},[127,691,692],{"class":129,"line":130},[127,693,694],{},"[Authentication]\n",[127,696,697],{"class":129,"line":144},[127,698,699],{},"access_token = \u003CACCESS_TOKEN>\n",[127,701,702],{"class":129,"line":154},[127,703,704],{},"app_key = \u003CAPP_KEY>\n",[127,706,707],{"class":129,"line":164},[127,708,709],{},"app_secret = \u003CAPP_SECRET>\n",[127,711,712],{"class":129,"line":174},[127,713,714],{},"refresh_token = \u003CREFRESH_TOKEN>\n",[10,716,287,717,82,720,82,722,636,724,727],{},[14,718,719],{},"ACCESS_TOKEN",[14,721,247],{},[14,723,450],{},[14,725,726],{},"REFRESH_TOKEN"," with the corresponding values:",[10,729,730,733,734,737,738,741,742,745,746,748],{},[14,731,732],{},"ACCESS_TOKEN:"," Your Dropbox app's generated access token.\n",[14,735,736],{},"APP_KEY:"," Your Dropbox app key.\n",[14,739,740],{},"APP_SECRET:"," Your Dropbox app secret.\n",[14,743,744],{},"REFRESH_TOKEN:"," The refresh token obtained from the ",[14,747,348],{}," script.",[10,750,751],{},"Save the credentials.ini file in the same directory as your Python scripts.",[10,753,754],{},[63,755],{"alt":756,"height":757,"src":758,"width":759},"The finished credentials.ini file with the four values filled in",212,"\u002Fimages\u002Fupload-files-to-dropbox-using-python\u002F08-credentials-ini.png",515,[23,761,763],{"id":762},"writing-the-python-script","Writing the Python Script",[10,765,766],{},"Now, let's create the Python script to upload a file to Dropbox. We'll use the Dropbox API and the dropbox Python library for seamless integration.",[117,768,770],{"className":195,"code":769,"language":197,"meta":122,"style":122},"import os\nimport dropbox\nimport requests\nimport configparser\n\nclass DropboxUploader:\n    def __init__(self):\n        # Configuration parameters\n        self.source_directory = \"\"\n        self.local_file_path = 'file.txt'\n        self.credentials_directory = \"credentials.ini\"\n        self.dropbox_directory = \"\u002Ffile_backups\"\n\n        # Initialize Dropbox API with access token\n        self.access_token = self.read_credentials_value(\"Authentication\", \"access_token\")\n        self.dbx = dropbox.Dropbox(self.access_token)\n\n    def read_credentials_value(self, section, key):\n        # Read a value from the credentials file\n        config = configparser.ConfigParser()\n        config.read(self.credentials_directory)\n\n        try:\n            return config.get(section, key)\n        except (configparser.NoSectionError, configparser.NoOptionError) as e:\n            print(f\"read_credentials_value function: Error reading config value: {e}\")\n            return None\n\n    def update_credentials_key_value(self, section, key, value):\n        # Update a key-value pair in the credentials file\n        config = configparser.ConfigParser()\n        config.read(self.credentials_directory)\n        config.set(section, key, value)\n\n        with open(self.credentials_directory, 'w') as config_file:\n            config.write(config_file)\n            print(f\"Key '{key}' value updated successfully in section '{section}'\")\n\n    def generate_new_access_token(self, app_key, app_secret, refresh_token):\n        # Generate a new access token using the provided credentials\n        url = \"https:\u002F\u002Fapi.dropbox.com\u002Foauth2\u002Ftoken\"\n        headers = {\"Content-Type\": \"application\u002Fx-www-form-urlencoded\"}\n        data = {\n            \"grant_type\": \"refresh_token\",\n            \"refresh_token\": refresh_token,\n            \"client_id\": app_key,\n            \"client_secret\": app_secret,\n        }\n\n        response = requests.post(url, headers=headers, data=data)\n\n        if response.status_code == 200:\n            return response.json().get(\"access_token\")\n        else:\n            print(\"generate_new_access_token function: Failed to get a new access token.\")\n            print(f\"generate_new_access_token function: Status code: {response.status_code}\")\n            print(f\"generate_new_access_token function: Response: {response.text}\")\n            return None\n\n    def check_token_validity(self):\n        # Check if the existing token is still valid\n        try:\n            self.dbx.files_list_folder('')\n            print(\"Token is valid\")\n        except dropbox.exceptions.AuthError:\n            print(\"Token is expired, generating new access token ...\")\n            app_key = self.read_credentials_value(\"Authentication\", \"app_key\")\n            app_secret = self.read_credentials_value(\"Authentication\", \"app_secret\")\n            refresh_token = self.read_credentials_value(\"Authentication\", \"refresh_token\")\n            new_token = self.generate_new_access_token(app_key, app_secret, refresh_token)\n\n            if new_token:\n                self.update_credentials_key_value(\"Authentication\", \"access_token\", new_token)\n                self.access_token = new_token\n                self.dbx = dropbox.Dropbox(self.access_token)\n        except dropbox.exceptions.DropboxException as e:\n            print(\"check_token_validity function: An error occurred while checking the token:\", e)\n\n    def upload_files(self):\n        # Upload a file to Dropbox\n        try:\n            self.check_token_validity()\n            file_name = os.path.basename(self.local_file_path)\n\n            with open(self.local_file_path, \"rb\") as file:\n                self.dbx.files_upload(file.read(), f\"{self.dropbox_directory}\u002F{file_name}\", mode=dropbox.files.WriteMode(\"overwrite\"))\n                print(f\"File '{file_name}' uploaded successfully to Dropbox.\")\n\n        except Exception as e:\n            print(\"upload_files function: An error occurred:\", e)\n\ndef main():\n    # Main program flow\n    print(\"Start uploading files ...\")\n    dropbox_uploader = DropboxUploader()\n    dropbox_uploader.upload_files()\n    print(\"End uploading files\")\n\nif __name__ == \"__main__\":\n    main()\n",[124,771,772,779,785,791,797,801,812,829,835,850,864,878,892,896,901,933,954,958,982,987,1005,1018,1023,1031,1048,1079,1103,1112,1117,1144,1150,1165,1176,1189,1194,1220,1234,1268,1273,1302,1308,1319,1340,1350,1363,1375,1387,1399,1405,1410,1437,1442,1464,1487,1495,1507,1530,1553,1560,1565,1579,1585,1592,1615,1627,1646,1658,1683,1708,1733,1751,1756,1767,1789,1803,1822,1844,1857,1862,1876,1882,1889,1901,1925,1930,1953,2016,2040,2045,2059,2071,2076,2088,2094,2107,2119,2132,2144,2149,2166],{"__ignoreMap":122},[127,773,774,776],{"class":129,"line":130},[127,775,205],{"class":204},[127,777,778],{"class":208}," os\n",[127,780,781,783],{"class":129,"line":144},[127,782,205],{"class":204},[127,784,141],{"class":208},[127,786,787,789],{"class":129,"line":154},[127,788,205],{"class":204},[127,790,151],{"class":208},[127,792,793,795],{"class":129,"line":164},[127,794,205],{"class":204},[127,796,161],{"class":208},[127,798,799],{"class":129,"line":174},[127,800,215],{"emptyLinePlaceholder":214},[127,802,803,806,809],{"class":129,"line":268},[127,804,805],{"class":204},"class",[127,807,808],{"class":133}," DropboxUploader",[127,810,811],{"class":208},":\n",[127,813,814,817,820,822,826],{"class":129,"line":273},[127,815,816],{"class":204},"    def",[127,818,819],{"class":133}," __init__",[127,821,430],{"class":208},[127,823,825],{"class":824},"sip0z","self",[127,827,828],{"class":208},"):\n",[127,830,831],{"class":129,"line":409},[127,832,834],{"class":833},"srwKs","        # Configuration parameters\n",[127,836,837,840,842,845,847],{"class":129,"line":414},[127,838,839],{"class":208},"        self",[127,841,47],{"class":256},[127,843,844],{"class":208},"source_directory ",[127,846,223],{"class":204},[127,848,849],{"class":226}," \"\"\n",[127,851,852,854,856,859,861],{"class":129,"line":465},[127,853,839],{"class":208},[127,855,47],{"class":256},[127,857,858],{"class":208},"local_file_path ",[127,860,223],{"class":204},[127,862,863],{"class":226}," 'file.txt'\n",[127,865,866,868,870,873,875],{"class":129,"line":470},[127,867,839],{"class":208},[127,869,47],{"class":256},[127,871,872],{"class":208},"credentials_directory ",[127,874,223],{"class":204},[127,876,877],{"class":226}," \"credentials.ini\"\n",[127,879,880,882,884,887,889],{"class":129,"line":481},[127,881,839],{"class":208},[127,883,47],{"class":256},[127,885,886],{"class":208},"dropbox_directory ",[127,888,223],{"class":204},[127,890,891],{"class":226}," \"\u002Ffile_backups\"\n",[127,893,894],{"class":129,"line":507},[127,895,215],{"emptyLinePlaceholder":214},[127,897,898],{"class":129,"line":520},[127,899,900],{"class":833},"        # Initialize Dropbox API with access token\n",[127,902,903,905,907,910,912,915,917,920,922,925,927,930],{"class":129,"line":526},[127,904,839],{"class":208},[127,906,47],{"class":256},[127,908,909],{"class":208},"access_token ",[127,911,223],{"class":204},[127,913,914],{"class":208}," self",[127,916,47],{"class":256},[127,918,919],{"class":133},"read_credentials_value",[127,921,430],{"class":256},[127,923,924],{"class":226},"\"Authentication\"",[127,926,82],{"class":256},[127,928,929],{"class":226},"\"access_token\"",[127,931,932],{"class":256},")\n",[127,934,935,937,939,942,944,947,949,951],{"class":129,"line":531},[127,936,839],{"class":208},[127,938,47],{"class":256},[127,940,941],{"class":208},"dbx ",[127,943,223],{"class":204},[127,945,946],{"class":208}," dropbox",[127,948,47],{"class":256},[127,950,16],{"class":133},[127,952,953],{"class":256},"(self.access_token)\n",[127,955,956],{"class":129,"line":554},[127,957,215],{"emptyLinePlaceholder":214},[127,959,960,962,965,967,969,972,975,977,980],{"class":129,"line":559},[127,961,816],{"class":204},[127,963,964],{"class":133}," read_credentials_value",[127,966,430],{"class":208},[127,968,825],{"class":824},[127,970,971],{"class":256},",",[127,973,974],{"class":824}," section",[127,976,971],{"class":256},[127,978,979],{"class":824}," key",[127,981,828],{"class":208},[127,983,984],{"class":129,"line":582},[127,985,986],{"class":833},"        # Read a value from the credentials file\n",[127,988,989,992,994,997,999,1002],{"class":129,"line":593},[127,990,991],{"class":208},"        config ",[127,993,223],{"class":204},[127,995,996],{"class":208}," configparser",[127,998,47],{"class":256},[127,1000,1001],{"class":133},"ConfigParser",[127,1003,1004],{"class":256},"()\n",[127,1006,1007,1010,1012,1015],{"class":129,"line":604},[127,1008,1009],{"class":208},"        config",[127,1011,47],{"class":256},[127,1013,1014],{"class":133},"read",[127,1016,1017],{"class":256},"(self.credentials_directory)\n",[127,1019,1021],{"class":129,"line":1020},22,[127,1022,215],{"emptyLinePlaceholder":214},[127,1024,1026,1029],{"class":129,"line":1025},23,[127,1027,1028],{"class":204},"        try",[127,1030,811],{"class":256},[127,1032,1034,1037,1040,1042,1045],{"class":129,"line":1033},24,[127,1035,1036],{"class":204},"            return",[127,1038,1039],{"class":208}," config",[127,1041,47],{"class":256},[127,1043,1044],{"class":133},"get",[127,1046,1047],{"class":256},"(section, key)\n",[127,1049,1051,1054,1057,1059,1062,1064,1066,1068,1071,1074,1077],{"class":129,"line":1050},25,[127,1052,1053],{"class":204},"        except",[127,1055,1056],{"class":208}," (configparser",[127,1058,47],{"class":256},[127,1060,1061],{"class":208},"NoSectionError",[127,1063,971],{"class":256},[127,1065,996],{"class":208},[127,1067,47],{"class":256},[127,1069,1070],{"class":208},"NoOptionError) ",[127,1072,1073],{"class":204},"as",[127,1075,1076],{"class":208}," e",[127,1078,811],{"class":256},[127,1080,1082,1085,1087,1089,1092,1094,1097,1099,1101],{"class":129,"line":1081},26,[127,1083,1084],{"class":133},"            print",[127,1086,430],{"class":256},[127,1088,433],{"class":204},[127,1090,1091],{"class":226},"\"read_credentials_value function: Error reading config value: ",[127,1093,244],{"class":243},[127,1095,1096],{"class":256},"e",[127,1098,250],{"class":243},[127,1100,501],{"class":226},[127,1102,932],{"class":256},[127,1104,1106,1108],{"class":129,"line":1105},27,[127,1107,1036],{"class":204},[127,1109,1111],{"class":1110},"svlcY"," None\n",[127,1113,1115],{"class":129,"line":1114},28,[127,1116,215],{"emptyLinePlaceholder":214},[127,1118,1120,1122,1125,1127,1129,1131,1133,1135,1137,1139,1142],{"class":129,"line":1119},29,[127,1121,816],{"class":204},[127,1123,1124],{"class":133}," update_credentials_key_value",[127,1126,430],{"class":208},[127,1128,825],{"class":824},[127,1130,971],{"class":256},[127,1132,974],{"class":824},[127,1134,971],{"class":256},[127,1136,979],{"class":824},[127,1138,971],{"class":256},[127,1140,1141],{"class":824}," value",[127,1143,828],{"class":208},[127,1145,1147],{"class":129,"line":1146},30,[127,1148,1149],{"class":833},"        # Update a key-value pair in the credentials file\n",[127,1151,1153,1155,1157,1159,1161,1163],{"class":129,"line":1152},31,[127,1154,991],{"class":208},[127,1156,223],{"class":204},[127,1158,996],{"class":208},[127,1160,47],{"class":256},[127,1162,1001],{"class":133},[127,1164,1004],{"class":256},[127,1166,1168,1170,1172,1174],{"class":129,"line":1167},32,[127,1169,1009],{"class":208},[127,1171,47],{"class":256},[127,1173,1014],{"class":133},[127,1175,1017],{"class":256},[127,1177,1179,1181,1183,1186],{"class":129,"line":1178},33,[127,1180,1009],{"class":208},[127,1182,47],{"class":256},[127,1184,1185],{"class":133},"set",[127,1187,1188],{"class":256},"(section, key, value)\n",[127,1190,1192],{"class":129,"line":1191},34,[127,1193,215],{"emptyLinePlaceholder":214},[127,1195,1197,1200,1203,1206,1209,1212,1215,1218],{"class":129,"line":1196},35,[127,1198,1199],{"class":204},"        with",[127,1201,1202],{"class":133}," open",[127,1204,1205],{"class":256},"(self.credentials_directory, ",[127,1207,1208],{"class":226},"'w'",[127,1210,1211],{"class":256},")",[127,1213,1214],{"class":204}," as",[127,1216,1217],{"class":208}," config_file",[127,1219,811],{"class":256},[127,1221,1223,1226,1228,1231],{"class":129,"line":1222},36,[127,1224,1225],{"class":208},"            config",[127,1227,47],{"class":256},[127,1229,1230],{"class":133},"write",[127,1232,1233],{"class":256},"(config_file)\n",[127,1235,1237,1239,1241,1243,1246,1248,1251,1253,1256,1258,1261,1263,1266],{"class":129,"line":1236},37,[127,1238,1084],{"class":133},[127,1240,430],{"class":256},[127,1242,433],{"class":204},[127,1244,1245],{"class":226},"\"Key '",[127,1247,244],{"class":243},[127,1249,1250],{"class":256},"key",[127,1252,250],{"class":243},[127,1254,1255],{"class":226},"' value updated successfully in section '",[127,1257,244],{"class":243},[127,1259,1260],{"class":256},"section",[127,1262,250],{"class":243},[127,1264,1265],{"class":226},"'\"",[127,1267,932],{"class":256},[127,1269,1271],{"class":129,"line":1270},38,[127,1272,215],{"emptyLinePlaceholder":214},[127,1274,1276,1278,1281,1283,1285,1287,1290,1292,1295,1297,1300],{"class":129,"line":1275},39,[127,1277,816],{"class":204},[127,1279,1280],{"class":133}," generate_new_access_token",[127,1282,430],{"class":208},[127,1284,825],{"class":824},[127,1286,971],{"class":256},[127,1288,1289],{"class":824}," app_key",[127,1291,971],{"class":256},[127,1293,1294],{"class":824}," app_secret",[127,1296,971],{"class":256},[127,1298,1299],{"class":824}," refresh_token",[127,1301,828],{"class":208},[127,1303,1305],{"class":129,"line":1304},40,[127,1306,1307],{"class":833},"        # Generate a new access token using the provided credentials\n",[127,1309,1311,1314,1316],{"class":129,"line":1310},41,[127,1312,1313],{"class":208},"        url ",[127,1315,223],{"class":204},[127,1317,1318],{"class":226}," \"https:\u002F\u002Fapi.dropbox.com\u002Foauth2\u002Ftoken\"\n",[127,1320,1322,1325,1327,1330,1333,1335,1338],{"class":129,"line":1321},42,[127,1323,1324],{"class":208},"        headers ",[127,1326,223],{"class":204},[127,1328,1329],{"class":256}," {",[127,1331,1332],{"class":226},"\"Content-Type\"",[127,1334,445],{"class":256},[127,1336,1337],{"class":226}," \"application\u002Fx-www-form-urlencoded\"",[127,1339,523],{"class":256},[127,1341,1343,1346,1348],{"class":129,"line":1342},43,[127,1344,1345],{"class":208},"        data ",[127,1347,223],{"class":204},[127,1349,478],{"class":256},[127,1351,1353,1356,1358,1361],{"class":129,"line":1352},44,[127,1354,1355],{"class":226},"            \"grant_type\"",[127,1357,445],{"class":256},[127,1359,1360],{"class":226}," \"refresh_token\"",[127,1362,504],{"class":256},[127,1364,1366,1369,1371,1373],{"class":129,"line":1365},45,[127,1367,1368],{"class":226},"            \"refresh_token\"",[127,1370,445],{"class":256},[127,1372,1299],{"class":208},[127,1374,504],{"class":256},[127,1376,1378,1381,1383,1385],{"class":129,"line":1377},46,[127,1379,1380],{"class":226},"            \"client_id\"",[127,1382,445],{"class":256},[127,1384,1289],{"class":208},[127,1386,504],{"class":256},[127,1388,1390,1393,1395,1397],{"class":129,"line":1389},47,[127,1391,1392],{"class":226},"            \"client_secret\"",[127,1394,445],{"class":256},[127,1396,1294],{"class":208},[127,1398,504],{"class":256},[127,1400,1402],{"class":129,"line":1401},48,[127,1403,1404],{"class":256},"        }\n",[127,1406,1408],{"class":129,"line":1407},49,[127,1409,215],{"emptyLinePlaceholder":214},[127,1411,1413,1416,1418,1420,1422,1424,1427,1429,1432,1434],{"class":129,"line":1412},50,[127,1414,1415],{"class":208},"        response ",[127,1417,223],{"class":204},[127,1419,567],{"class":208},[127,1421,47],{"class":256},[127,1423,572],{"class":133},[127,1425,1426],{"class":256},"(url, headers",[127,1428,223],{"class":204},[127,1430,1431],{"class":256},"headers, data",[127,1433,223],{"class":204},[127,1435,1436],{"class":256},"data)\n",[127,1438,1440],{"class":129,"line":1439},51,[127,1441,215],{"emptyLinePlaceholder":214},[127,1443,1445,1448,1451,1453,1456,1459,1462],{"class":129,"line":1444},52,[127,1446,1447],{"class":204},"        if",[127,1449,1450],{"class":208}," response",[127,1452,47],{"class":256},[127,1454,1455],{"class":208},"status_code ",[127,1457,1458],{"class":204},"==",[127,1460,1461],{"class":243}," 200",[127,1463,811],{"class":256},[127,1465,1467,1469,1471,1473,1476,1479,1481,1483,1485],{"class":129,"line":1466},53,[127,1468,1036],{"class":204},[127,1470,1450],{"class":208},[127,1472,47],{"class":256},[127,1474,1475],{"class":133},"json",[127,1477,1478],{"class":256},"().",[127,1480,1044],{"class":133},[127,1482,430],{"class":256},[127,1484,929],{"class":226},[127,1486,932],{"class":256},[127,1488,1490,1493],{"class":129,"line":1489},54,[127,1491,1492],{"class":204},"        else",[127,1494,811],{"class":256},[127,1496,1498,1500,1502,1505],{"class":129,"line":1497},55,[127,1499,1084],{"class":133},[127,1501,430],{"class":256},[127,1503,1504],{"class":226},"\"generate_new_access_token function: Failed to get a new access token.\"",[127,1506,932],{"class":256},[127,1508,1510,1512,1514,1516,1519,1521,1524,1526,1528],{"class":129,"line":1509},56,[127,1511,1084],{"class":133},[127,1513,430],{"class":256},[127,1515,433],{"class":204},[127,1517,1518],{"class":226},"\"generate_new_access_token function: Status code: ",[127,1520,244],{"class":243},[127,1522,1523],{"class":256},"response.status_code",[127,1525,250],{"class":243},[127,1527,501],{"class":226},[127,1529,932],{"class":256},[127,1531,1533,1535,1537,1539,1542,1544,1547,1549,1551],{"class":129,"line":1532},57,[127,1534,1084],{"class":133},[127,1536,430],{"class":256},[127,1538,433],{"class":204},[127,1540,1541],{"class":226},"\"generate_new_access_token function: Response: ",[127,1543,244],{"class":243},[127,1545,1546],{"class":256},"response.text",[127,1548,250],{"class":243},[127,1550,501],{"class":226},[127,1552,932],{"class":256},[127,1554,1556,1558],{"class":129,"line":1555},58,[127,1557,1036],{"class":204},[127,1559,1111],{"class":1110},[127,1561,1563],{"class":129,"line":1562},59,[127,1564,215],{"emptyLinePlaceholder":214},[127,1566,1568,1570,1573,1575,1577],{"class":129,"line":1567},60,[127,1569,816],{"class":204},[127,1571,1572],{"class":133}," check_token_validity",[127,1574,430],{"class":208},[127,1576,825],{"class":824},[127,1578,828],{"class":208},[127,1580,1582],{"class":129,"line":1581},61,[127,1583,1584],{"class":833},"        # Check if the existing token is still valid\n",[127,1586,1588,1590],{"class":129,"line":1587},62,[127,1589,1028],{"class":204},[127,1591,811],{"class":256},[127,1593,1595,1598,1600,1603,1605,1608,1610,1613],{"class":129,"line":1594},63,[127,1596,1597],{"class":208},"            self",[127,1599,47],{"class":256},[127,1601,1602],{"class":208},"dbx",[127,1604,47],{"class":256},[127,1606,1607],{"class":133},"files_list_folder",[127,1609,430],{"class":256},[127,1611,1612],{"class":226},"''",[127,1614,932],{"class":256},[127,1616,1618,1620,1622,1625],{"class":129,"line":1617},64,[127,1619,1084],{"class":133},[127,1621,430],{"class":256},[127,1623,1624],{"class":226},"\"Token is valid\"",[127,1626,932],{"class":256},[127,1628,1630,1632,1634,1636,1639,1641,1644],{"class":129,"line":1629},65,[127,1631,1053],{"class":204},[127,1633,946],{"class":208},[127,1635,47],{"class":256},[127,1637,1638],{"class":208},"exceptions",[127,1640,47],{"class":256},[127,1642,1643],{"class":208},"AuthError",[127,1645,811],{"class":256},[127,1647,1649,1651,1653,1656],{"class":129,"line":1648},66,[127,1650,1084],{"class":133},[127,1652,430],{"class":256},[127,1654,1655],{"class":226},"\"Token is expired, generating new access token ...\"",[127,1657,932],{"class":256},[127,1659,1661,1664,1666,1668,1670,1672,1674,1676,1678,1681],{"class":129,"line":1660},67,[127,1662,1663],{"class":208},"            app_key ",[127,1665,223],{"class":204},[127,1667,914],{"class":208},[127,1669,47],{"class":256},[127,1671,919],{"class":133},[127,1673,430],{"class":256},[127,1675,924],{"class":226},[127,1677,82],{"class":256},[127,1679,1680],{"class":226},"\"app_key\"",[127,1682,932],{"class":256},[127,1684,1686,1689,1691,1693,1695,1697,1699,1701,1703,1706],{"class":129,"line":1685},68,[127,1687,1688],{"class":208},"            app_secret ",[127,1690,223],{"class":204},[127,1692,914],{"class":208},[127,1694,47],{"class":256},[127,1696,919],{"class":133},[127,1698,430],{"class":256},[127,1700,924],{"class":226},[127,1702,82],{"class":256},[127,1704,1705],{"class":226},"\"app_secret\"",[127,1707,932],{"class":256},[127,1709,1711,1714,1716,1718,1720,1722,1724,1726,1728,1731],{"class":129,"line":1710},69,[127,1712,1713],{"class":208},"            refresh_token ",[127,1715,223],{"class":204},[127,1717,914],{"class":208},[127,1719,47],{"class":256},[127,1721,919],{"class":133},[127,1723,430],{"class":256},[127,1725,924],{"class":226},[127,1727,82],{"class":256},[127,1729,1730],{"class":226},"\"refresh_token\"",[127,1732,932],{"class":256},[127,1734,1736,1739,1741,1743,1745,1748],{"class":129,"line":1735},70,[127,1737,1738],{"class":208},"            new_token ",[127,1740,223],{"class":204},[127,1742,914],{"class":208},[127,1744,47],{"class":256},[127,1746,1747],{"class":133},"generate_new_access_token",[127,1749,1750],{"class":256},"(app_key, app_secret, refresh_token)\n",[127,1752,1754],{"class":129,"line":1753},71,[127,1755,215],{"emptyLinePlaceholder":214},[127,1757,1759,1762,1765],{"class":129,"line":1758},72,[127,1760,1761],{"class":204},"            if",[127,1763,1764],{"class":208}," new_token",[127,1766,811],{"class":256},[127,1768,1770,1773,1775,1778,1780,1782,1784,1786],{"class":129,"line":1769},73,[127,1771,1772],{"class":208},"                self",[127,1774,47],{"class":256},[127,1776,1777],{"class":133},"update_credentials_key_value",[127,1779,430],{"class":256},[127,1781,924],{"class":226},[127,1783,82],{"class":256},[127,1785,929],{"class":226},[127,1787,1788],{"class":256},", new_token)\n",[127,1790,1792,1794,1796,1798,1800],{"class":129,"line":1791},74,[127,1793,1772],{"class":208},[127,1795,47],{"class":256},[127,1797,909],{"class":208},[127,1799,223],{"class":204},[127,1801,1802],{"class":208}," new_token\n",[127,1804,1806,1808,1810,1812,1814,1816,1818,1820],{"class":129,"line":1805},75,[127,1807,1772],{"class":208},[127,1809,47],{"class":256},[127,1811,941],{"class":208},[127,1813,223],{"class":204},[127,1815,946],{"class":208},[127,1817,47],{"class":256},[127,1819,16],{"class":133},[127,1821,953],{"class":256},[127,1823,1825,1827,1829,1831,1833,1835,1838,1840,1842],{"class":129,"line":1824},76,[127,1826,1053],{"class":204},[127,1828,946],{"class":208},[127,1830,47],{"class":256},[127,1832,1638],{"class":208},[127,1834,47],{"class":256},[127,1836,1837],{"class":208},"DropboxException ",[127,1839,1073],{"class":204},[127,1841,1076],{"class":208},[127,1843,811],{"class":256},[127,1845,1847,1849,1851,1854],{"class":129,"line":1846},77,[127,1848,1084],{"class":133},[127,1850,430],{"class":256},[127,1852,1853],{"class":226},"\"check_token_validity function: An error occurred while checking the token:\"",[127,1855,1856],{"class":256},", e)\n",[127,1858,1860],{"class":129,"line":1859},78,[127,1861,215],{"emptyLinePlaceholder":214},[127,1863,1865,1867,1870,1872,1874],{"class":129,"line":1864},79,[127,1866,816],{"class":204},[127,1868,1869],{"class":133}," upload_files",[127,1871,430],{"class":208},[127,1873,825],{"class":824},[127,1875,828],{"class":208},[127,1877,1879],{"class":129,"line":1878},80,[127,1880,1881],{"class":833},"        # Upload a file to Dropbox\n",[127,1883,1885,1887],{"class":129,"line":1884},81,[127,1886,1028],{"class":204},[127,1888,811],{"class":256},[127,1890,1892,1894,1896,1899],{"class":129,"line":1891},82,[127,1893,1597],{"class":208},[127,1895,47],{"class":256},[127,1897,1898],{"class":133},"check_token_validity",[127,1900,1004],{"class":256},[127,1902,1904,1907,1909,1912,1914,1917,1919,1922],{"class":129,"line":1903},83,[127,1905,1906],{"class":208},"            file_name ",[127,1908,223],{"class":204},[127,1910,1911],{"class":208}," os",[127,1913,47],{"class":256},[127,1915,1916],{"class":208},"path",[127,1918,47],{"class":256},[127,1920,1921],{"class":133},"basename",[127,1923,1924],{"class":256},"(self.local_file_path)\n",[127,1926,1928],{"class":129,"line":1927},84,[127,1929,215],{"emptyLinePlaceholder":214},[127,1931,1933,1936,1938,1941,1944,1946,1948,1951],{"class":129,"line":1932},85,[127,1934,1935],{"class":204},"            with",[127,1937,1202],{"class":133},[127,1939,1940],{"class":256},"(self.local_file_path, ",[127,1942,1943],{"class":226},"\"rb\"",[127,1945,1211],{"class":256},[127,1947,1214],{"class":204},[127,1949,1950],{"class":208}," file",[127,1952,811],{"class":256},[127,1954,1956,1958,1960,1962,1964,1967,1970,1972,1975,1977,1979,1981,1984,1986,1989,1991,1994,1996,1998,2001,2003,2006,2009,2011,2014],{"class":129,"line":1955},86,[127,1957,1772],{"class":208},[127,1959,47],{"class":256},[127,1961,1602],{"class":208},[127,1963,47],{"class":256},[127,1965,1966],{"class":133},"files_upload",[127,1968,1969],{"class":256},"(file.",[127,1971,1014],{"class":133},[127,1973,1974],{"class":256},"(), ",[127,1976,433],{"class":204},[127,1978,501],{"class":226},[127,1980,244],{"class":243},[127,1982,1983],{"class":256},"self.dropbox_directory",[127,1985,250],{"class":243},[127,1987,1988],{"class":226},"\u002F",[127,1990,244],{"class":243},[127,1992,1993],{"class":256},"file_name",[127,1995,250],{"class":243},[127,1997,501],{"class":226},[127,1999,2000],{"class":256},", mode",[127,2002,223],{"class":204},[127,2004,2005],{"class":256},"dropbox.files.",[127,2007,2008],{"class":133},"WriteMode",[127,2010,430],{"class":256},[127,2012,2013],{"class":226},"\"overwrite\"",[127,2015,629],{"class":256},[127,2017,2019,2022,2024,2026,2029,2031,2033,2035,2038],{"class":129,"line":2018},87,[127,2020,2021],{"class":133},"                print",[127,2023,430],{"class":256},[127,2025,433],{"class":204},[127,2027,2028],{"class":226},"\"File '",[127,2030,244],{"class":243},[127,2032,1993],{"class":256},[127,2034,250],{"class":243},[127,2036,2037],{"class":226},"' uploaded successfully to Dropbox.\"",[127,2039,932],{"class":256},[127,2041,2043],{"class":129,"line":2042},88,[127,2044,215],{"emptyLinePlaceholder":214},[127,2046,2048,2050,2053,2055,2057],{"class":129,"line":2047},89,[127,2049,1053],{"class":204},[127,2051,2052],{"class":1110}," Exception",[127,2054,1214],{"class":204},[127,2056,1076],{"class":208},[127,2058,811],{"class":256},[127,2060,2062,2064,2066,2069],{"class":129,"line":2061},90,[127,2063,1084],{"class":133},[127,2065,430],{"class":256},[127,2067,2068],{"class":226},"\"upload_files function: An error occurred:\"",[127,2070,1856],{"class":256},[127,2072,2074],{"class":129,"line":2073},91,[127,2075,215],{"emptyLinePlaceholder":214},[127,2077,2079,2082,2085],{"class":129,"line":2078},92,[127,2080,2081],{"class":204},"def",[127,2083,2084],{"class":133}," main",[127,2086,2087],{"class":208},"():\n",[127,2089,2091],{"class":129,"line":2090},93,[127,2092,2093],{"class":833},"    # Main program flow\n",[127,2095,2097,2100,2102,2105],{"class":129,"line":2096},94,[127,2098,2099],{"class":133},"    print",[127,2101,430],{"class":256},[127,2103,2104],{"class":226},"\"Start uploading files ...\"",[127,2106,932],{"class":256},[127,2108,2110,2113,2115,2117],{"class":129,"line":2109},95,[127,2111,2112],{"class":208},"    dropbox_uploader ",[127,2114,223],{"class":204},[127,2116,808],{"class":133},[127,2118,1004],{"class":256},[127,2120,2122,2125,2127,2130],{"class":129,"line":2121},96,[127,2123,2124],{"class":208},"    dropbox_uploader",[127,2126,47],{"class":256},[127,2128,2129],{"class":133},"upload_files",[127,2131,1004],{"class":256},[127,2133,2135,2137,2139,2142],{"class":129,"line":2134},97,[127,2136,2099],{"class":133},[127,2138,430],{"class":256},[127,2140,2141],{"class":226},"\"End uploading files\"",[127,2143,932],{"class":256},[127,2145,2147],{"class":129,"line":2146},98,[127,2148,215],{"emptyLinePlaceholder":214},[127,2150,2152,2155,2158,2161,2164],{"class":129,"line":2151},99,[127,2153,2154],{"class":204},"if",[127,2156,2157],{"class":1110}," __name__",[127,2159,2160],{"class":204}," ==",[127,2162,2163],{"class":226}," \"__main__\"",[127,2165,811],{"class":256},[127,2167,2169,2172],{"class":129,"line":2168},100,[127,2170,2171],{"class":133},"    main",[127,2173,1004],{"class":256},[10,2175,2176],{},"Now that your Python script is ready, you can run it to upload a file to your Dropbox account. Execute the following command in your terminal or command prompt:",[117,2178,2180],{"className":119,"code":2179,"language":121,"meta":122,"style":122},"python main.py\n",[124,2181,2182],{"__ignoreMap":122},[127,2183,2184,2186],{"class":129,"line":130},[127,2185,197],{"class":133},[127,2187,2188],{"class":137}," main.py\n",[23,2190,2192],{"id":2191},"conclusion","Conclusion",[10,2194,2195],{},"Congratulations! You've successfully created a Python script to upload files to Dropbox.",[10,2197,2198],{},"Feel free to customize the script further based on your specific requirements. You can add error handling, implement batch uploads, or integrate it into a larger project for a more comprehensive solution.",[10,2200,2201,2202,47],{},"You can also clone the app from GitHub: ",[41,2203,2206],{"href":2204,"rel":2205},"https:\u002F\u002Fgithub.com\u002Frekanos\u002Fpython-dropbox-file-uploader",[45],"python-dropbox-file-uploader",[2208,2209,2210],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sXSfg, html code.shiki .sXSfg{--shiki-default:#2B5581;--shiki-dark:#9DB1C5}html pre.shiki code .se1w0, html code.shiki .se1w0{--shiki-default:#D32F2F;--shiki-dark:#F97583}html pre.shiki code .sHHeI, html code.shiki .sHHeI{--shiki-default:#24292EFF;--shiki-dark:#B392F0}html pre.shiki code .sxIrz, html code.shiki .sxIrz{--shiki-default:#22863A;--shiki-dark:#FFAB70}html pre.shiki code .soJJD, html code.shiki .soJJD{--shiki-default:#1976D2;--shiki-dark:#F8F8F8}html pre.shiki code .som3e, html code.shiki .som3e{--shiki-default:#212121;--shiki-dark:#BBBBBB}html pre.shiki code .sip0z, html code.shiki .sip0z{--shiki-default:#FF9800;--shiki-dark:#FF9800}html pre.shiki code .srwKs, html code.shiki .srwKs{--shiki-default:#C2C3C5;--shiki-dark:#6B737C}html pre.shiki code .svlcY, html code.shiki .svlcY{--shiki-default:#1976D2;--shiki-dark:#79B8FF}",{"title":122,"searchDepth":144,"depth":144,"links":2212},[2213,2214,2215,2216,2217,2218,2219,2220],{"id":25,"depth":144,"text":26},{"id":50,"depth":144,"text":51},{"id":111,"depth":144,"text":112},{"id":184,"depth":144,"text":185},{"id":342,"depth":144,"text":343},{"id":672,"depth":144,"text":673},{"id":762,"depth":144,"text":763},{"id":2191,"depth":144,"text":2192},"2024-03-14","A Python script that uploads files to Dropbox and refreshes its own access token, so scheduled backups keep working without manual re-authorization.",false,"md",{},"\u002Fwriting\u002F2024-03-14-upload-files-to-dropbox-using-python",{"title":5,"description":2222},"writing\u002F2024-03-14-upload-files-to-dropbox-using-python",[197,2230,2231,2232],"dropbox","automation","backup",null,"ZvFwK9_A4I9S4ik5N9CaoAQRDfFTH17YNed9NJ2lC7g",[2236,2233],{"title":2237,"path":2238,"stem":2239,"date":2240,"children":-1},"A Reliable Way to Prevent Duplicate Database Records","\u002Fwriting\u002F2026-07-17-a-reliable-way-to-prevent-duplicate-database-records","writing\u002F2026-07-17-a-reliable-way-to-prevent-duplicate-database-records","2026-07-17",1784291271594]