Fix a bug where only basic auth would work

This commit is contained in:
Markus Unterwaditzer 2014-05-18 19:43:09 +02:00
parent 5c6806ce97
commit 29405f59ef

View file

@ -15,12 +15,14 @@ USERAGENT = 'vdirsyncer'
def prepare_auth(auth, username, password):
if (username and password) or auth == 'basic':
if auth == 'basic':
return (username, password)
elif auth == 'digest':
from requests.auth import HTTPDigestAuth
return HTTPDigestAuth(username, password)
elif auth is None:
if username and password:
return (username, password)
return None
else:
raise ValueError('Unknown authentication method: {}'.format(auth))