I tried the following

```python
if 'apache_user' in instance and 'apache_password' in instance:
            auth_handler = urllib2.HTTPBasicAuthHandler()
            auth_handler.add_password(realm="Apache",
                                      uri=url,
                                      user=instance['apache_user'],
                                      passwd=instance['apache_password'])
            opener = urllib2.build_opener(auth_handler)
            urllib2.install_opener(opener)
request = urllib2.urlopen(req)
```
but I kept getting 401 errors.

A few sources have suggested to manually encode the authorization header, specifically http://stackoverflow.com/questions/635113/python-urllib2-basic-http-authentication-and-tr-im and http://community.pivotaltracker.com/pivotal/topics/401_unauthorized_python_basic_auto. Not sure if I'm using HTTPBasicAuthHandler incorrectly in the snippet above - from the documentation it appears that should work. What do you think, Remi?