From e838e5b514c6b78333db9f6b79b6f8c48d9a6eb8 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 22 May 2023 21:36:04 -0500 Subject: [PATCH] Add support for htdigest auth when using CORE webservices API --- rattail_corepos/corepos/api.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/rattail_corepos/corepos/api.py b/rattail_corepos/corepos/api.py index 69d98c5..f13af2c 100644 --- a/rattail_corepos/corepos/api.py +++ b/rattail_corepos/corepos/api.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2021 Lance Edgar +# Copyright © 2010-2023 Lance Edgar # # This file is part of Rattail. # @@ -24,6 +24,8 @@ CORE-POS API """ +from requests.auth import HTTPDigestAuth + from corepos.api import CoreWebAPI @@ -32,4 +34,12 @@ def make_corepos_api(config): Make and return a new CORE-POS API client object. """ 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)