Basic Auth in Python
While hacking about with Google App Engine I decided to integrate some Twitter APIs. The code below is a quick method for access urls that require basic auth such as your Twitter timeline
authstring = base64.encodestring('%s:%s' % ('username', 'password'))
authstring = authstring.replace('\n', '')
r = urlfetch.fetch("http://twitter.com/statuses/friends_timeline.atom", headers={'Content-Type': 'application/x-www-form-urlencoded','Authorization': 'Basic %s' % authstring})
self.response.out.write(r.content)

