-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_upload.py
More file actions
32 lines (20 loc) · 825 Bytes
/
setup_upload.py
File metadata and controls
32 lines (20 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Setup uploading to dropbox. Only run once
import dropbox
APP_KEY = "j3ttnh3r69s7kz3"
APP_SECRET = "ntb0ntwd2jp7jam"
auth_flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect(APP_KEY, APP_SECRET)
authorize_url = auth_flow.start()
print("1. Go to: " + authorize_url)
print("2. Click \"Allow\" (you might have to log in first).")
print("3. Copy the authorization code.")
auth_code = input("Enter the authorization code here: ").strip()
try:
oauth_result = auth_flow.finish(auth_code)
except Exception as e:
print('Error: %s' % (e,))
exit(1)
with dropbox.Dropbox(oauth2_access_token=oauth_result.access_token) as dbx:
dbx.users_get_current_account()
print("Successfully set up client!")
with open("access_token.py", "w") as conf:
conf.write(f"access_token = \042{dbx._oauth2_access_token}\042")