Delicious API and urllib2

B

Bill

The delicious api requires http authorization (actually https). A
generic delicious api post url is "https://
username:p[email protected]/v1/posts/add?url=http://
example.com/&description=interesting&tags=whatever".

This works fine when entered in the Firefox address bar. However
urllib2.urlopen(delicious_post_url) chokes and returns
"httplib.InvalidURL: nonnumeric port: '(e-mail address removed)".

Delicious really wants that authorization stuff embedded in the url as
it also rejected my attempts at using urllib2.HTTPBasicAuthHandler(),
etc.
Anybody have any hints?
 
B

Brent Bloxam

Bill said:
The delicious api requires http authorization (actually https). A
generic delicious api post url is "https://
username:p[email protected]/v1/posts/add?url=http://
example.com/&description=interesting&tags=whatever".

This works fine when entered in the Firefox address bar. However
urllib2.urlopen(delicious_post_url) chokes and returns
"httplib.InvalidURL: nonnumeric port: '(e-mail address removed)".

Delicious really wants that authorization stuff embedded in the url as
it also rejected my attempts at using urllib2.HTTPBasicAuthHandler(),
etc.
Anybody have any hints?
What failure were you experiencing when you were using the
HTTPBasicAuthHandler?

Did you follow the sample code from the docs?
 
M

Max Erickson

Bill said:
The delicious api requires http authorization (actually https). A
generic delicious api post url is "https://
username:p[email protected]/v1/posts/add?url=http://
example.com/&description=interesting&tags=whatever".

The simplest way is probably to manually add the authentication
header, as shown here:

http://code.activestate.com/recipes/267197/#c2

This article discusses the above strategy, and a strategy using
HTTPBasicAuthHandler with a password manager default realm (I think
getting the realm correct is what has stymied me in my attempts to use
handlers, rather than injecting the header):

http://www.voidspace.org.uk/python/articles/authentication.shtml


Max
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top