duosecurity/duo_client_python

sig v4 implementation does not work

ccassell opened this issue · 1 comments

For example (on macOS, but it fails regardless of the platform):

client = duo_client.client.Client(
	ikey=IKEY,
	skey=SKEY,
	host=HOST,
	digestmod=hashlib.sha512,
	sig_version=4,
)

data = client.json_api_call('GET', '/path/to/resource', {})

Raises:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 938, in urlencode
    raise TypeError
TypeError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 18, in <module>
    data = client.json_api_call('GET', '/path/to/resource', {})
  File "/usr/local/lib/python3.9/site-packages/duo_client/client.py", line 388, in json_api_call
    (response, data) = self.api_call(method, path, params)
  File "/usr/local/lib/python3.9/site-packages/duo_client/client.py", line 265, in api_call
    uri = path + '?' + six.moves.urllib.parse.urlencode(params, doseq=True)
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 945, in urlencode
    raise TypeError("not a valid non-string sequence "
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/parse.py", line 938, in urlencode
    raise TypeError
TypeError: not a valid non-string sequence or mapping object 

Fixed by #159