Skip to content

Instantly share code, notes, and snippets.

@seanieb
Forked from mikedewar/instapaper_xauth
Last active July 20, 2016 21:10
Show Gist options
  • Save seanieb/6983332 to your computer and use it in GitHub Desktop.
Save seanieb/6983332 to your computer and use it in GitHub Desktop.
from __future__ import unicode_literals
from urlparse import parse_qs
import requests
from requests_oauthlib import OAuth1
key = "key"
secret ="secret"
oauth = OAuth1(key, secret)
instaaccount = "username"
instapassword = "password"
params = {}
params["x_auth_username"] = instaaccount
params["x_auth_password"] = instapassword
params["x_auth_mode"] = 'client_auth'
request_token_url = 'https://www.instapaper.com/api/1/oauth/access_token'
r = requests.post(url=request_token_url, auth=oauth, data=params)
credentials = parse_qs(r.content)
oauth_token = credentials.get('oauth_token')[0]
oauth_secret = credentials.get('oauth_token_secret')[0]
oauth = OAuth1(key, secret+"&"+oauth_secret, oauth_token)
list_url = 'https://www.instapaper.com/api/1/bookmarks/list'
params = {
"username": instaaccount,
"password": instapassword
}
r = requests.post(list_url, auth=oauth, data=params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment