I'm trying to use Instapaper's simple developer api to add a url to my bookmarks using python and the requests library. To authenticate the username and password all works well.
import requests
from requests.auth import HTTPBasicAuth
requests.get('https://www.instapaper.com/api/authenticate', auth=HTTPBasicAuth('username', 'password'))
But when trying to use the api to add a bookmark:
requests.get('https://www.instapaper.com/api/add', auth=HTTPBasicAuth('username', 'password','websiteUrl'))
I get error:
File "instantbookmark.py", line 3, in <module>
getA = requests.get('https://www.instapaper.com/api/add', auth=HTTPBasicAuth('username', 'password','websiteUrl'))
TypeError: __init__() takes exactly 3 arguments (4 given)
I think this is because HTTPBasicAuth can't take a third argument, does anyone know a way to do this?
HTTPBasicAuth()
only ever takes username and password arguments. There is no 3rd argument, full-stop.
HTTP Basic Authentication adds an extra header to the request; this information is kept separate from the GET or POST parameters. When you use this form of authentication, you do not need to pass any username
and password
parameters to the API methods either.
To add a bookmark, pass in the url
parameter as a POST or GET data parameter:
requests.post('https://www.instapaper.com/api/add', data={'url': 'websiteUrl'}, auth=HTTPBasicAuth('username', 'password'))
Either requests.get()
or requests.post()
will do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With