Add support for htdigest auth when using CORE webservices API

This commit is contained in:
Lance Edgar 2023-05-22 21:36:04 -05:00
parent 66a6c8f5a0
commit e838e5b514

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2021 Lance Edgar # Copyright © 2010-2023 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -24,6 +24,8 @@
CORE-POS API CORE-POS API
""" """
from requests.auth import HTTPDigestAuth
from corepos.api import CoreWebAPI from corepos.api import CoreWebAPI
@ -32,4 +34,12 @@ def make_corepos_api(config):
Make and return a new CORE-POS API client object. Make and return a new CORE-POS API client object.
""" """
url = config.require('corepos.api', 'url') url = config.require('corepos.api', 'url')
return CoreWebAPI(url)
kwargs = {}
username = config.get('corepos.api', 'htdigest.username')
password = config.get('corepos.api', 'htdigest.password')
if username and password:
kwargs['htdigest_username'] = username
kwargs['htdigest_password'] = password
return CoreWebAPI(url, **kwargs)