-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth_and_fetch_bookmarks.py
More file actions
37 lines (29 loc) · 1.01 KB
/
auth_and_fetch_bookmarks.py
File metadata and controls
37 lines (29 loc) · 1.01 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
#!/usr/bin/env python
import getpass
import json
import os
import requests
from requests_oauthlib import OAuth1
import urllib
import sys
from instapaper_api_client import InstapaperApiClient
def main():
if len(sys.argv) != 2:
print('Usage: %s <login-email>' % sys.argv[0])
sys.exit(-1)
client_key = os.environ.get('INSTAPAPER_CLIENT_KEY')
client_secret = os.environ.get('INSTAPAPER_CLIENT_SECRET')
if not client_key or not client_secret:
print('Please set INSTAPAPER_CLIENT_KEY and INSTAPAPER_CLIENT_SECRET environment variables using your app OAuth credentials.')
sys.exit(-1)
email = sys.argv[1]
password = getpass.getpass()
instapaper = InstapaperApiClient(client_key, client_secret)
user_oauth = instapaper.authenticate_user(email, password)
if not user_oauth:
print('User authentication failed')
sys.exit(-1)
data = instapaper.list_bookmarks(user_oauth)
print(json.dumps(data, indent=4))
if __name__ == '__main__':
main()