13
votes

I'd like to know if the Google App Engine URL Fetch Python API does not support accessing URLs that have credentials:

http://username:[email protected]/

It should be a basic feature, but I cannot get it to work and could not find any documentation about it being supported or not as well.

1
stackoverflow.com/a/3268060/110707 (the question is about Java, but this answer addresses Python) - Wooble
you've nailed it @Wooble, thanks! - raugfer
@raugfer : Post your solution as an Answer - Gautam
@GautamK: Just did it, sorry, I'm a newbie here :) - raugfer

1 Answers

26
votes

SOLUTION - here's how it should be done:

result = urlfetch.fetch("http://www.domain.com/",
                        headers={"Authorization": 
                                 "Basic %s" % base64.b64encode("username:password")})