add option to use http basic auth to retrieve formdatas (#63469)
This commit is contained in:
parent
1efc9b6d49
commit
cede43de4b
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue