diff --git a/passerelle_montpellier_encombrants/management/commands/notify_sectors.py b/passerelle_montpellier_encombrants/management/commands/notify_sectors.py index 2264ca5..25ff7cc 100644 --- a/passerelle_montpellier_encombrants/management/commands/notify_sectors.py +++ b/passerelle_montpellier_encombrants/management/commands/notify_sectors.py @@ -16,9 +16,13 @@ class Command(BaseCommand): api_user = getattr(settings, 'ENCOMBRANTS_API_USER') secret = getattr(settings, 'ENCOMBRANTS_API_SECRET') orig = getattr(settings, 'ENCOMBRANTS_API_ORIG') - if sign: + use_http_auth = getattr(settings, 'ENCOMBRANTS_API_HTTP_AUTH', False) + kwargs = {} + if use_http_auth: + kwargs['auth'] = (settings.ENCOMBRANTS_API_HTTP_USERNAME, settings.ENCOMBRANTS_API_HTTP_PASSWORD) + elif sign: url = sign_url(url + '&email=' + urllib.quote(api_user), secret) + '&orig=' + urllib.quote(orig) - return requests.get(url, headers={'Accept': 'application/json'}) + return requests.get(url, headers={'Accept': 'application/json'}, *kwargs) def handle(self, *args, **kwargs): if not getattr(settings, 'ENCOMBRANTS_FORM_URL', None):