forked from Perlence/dropbox-via-webdav
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_access_token.py
More file actions
38 lines (31 loc) · 1.12 KB
/
Copy pathget_access_token.py
File metadata and controls
38 lines (31 loc) · 1.12 KB
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
28
29
30
31
32
33
34
35
36
37
38
from __future__ import print_function
from dropbox.client import DropboxOAuth2FlowNoRedirect
import config
def main():
consumer_key = getattr(config, 'CONSUMER_KEY', '')
consumer_secret = getattr(config, 'CONSUMER_SECRET', '')
if not (consumer_key and consumer_secret):
print('Error! Please provide CONSUMER_KEY and CONSUMER_SECRET in '
'config.json')
return
flow = DropboxOAuth2FlowNoRedirect(config.CONSUMER_KEY,
config.CONSUMER_SECRET)
url = flow.start()
print('Follow this link and grant access to ViaWebDAV:')
print(url, '\n')
code = raw_input('Enter the code: ').strip()
accessToken, userId = flow.finish(code)
print('Your access token: ', accessToken)
print("""
Put this token into section ACCESS_TOKENS of config.json, e.g.:
{
"CONSUMER_KEY": "...",
"CONSUMER_SECRET": "...",
"ACCESS_TOKENS": {
"": "<access-token>", // map the account to "/"
"alex": "<another-access-token>" // map the account to "/alex"
}
}
""")
if __name__ == '__main__':
main()