movinalot / intersight-rest-api

Intersight REST API interactions with Postman and Python
MIT License
7 stars 20 forks source link

TypeError: sign() takes 3 positional arguments but 4 were given #1

Open jwomack opened 4 years ago

jwomack commented 4 years ago

I was trying to work through the the "Introduction to the Cisco Intersight REST API with Python". When I run the intersight_ops.py I get: python intersight_ops.py GET Traceback (most recent call last): File "intersight_ops.py", line 108, in <module> response = requests.get( File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, **kwargs) File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\api.py", line 60, in request return session.request(method=method, url=url, **kwargs) File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\sessions.py", line 519, in request prep = self.prepare_request(req) File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\sessions.py", line 452, in prepare_request p.prepare( File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\models.py", line 317, in prepare self.prepare_auth(auth, url) File "C:\GitRepos\intersight-rest-api\intersight\lib\site-packages\requests\models.py", line 548, in prepare_auth r = auth(self) File "C:\GitRepos\intersight-rest-api\intersight_auth.py", line 107, in __call__ auth_header = _get_auth_header( File "C:\GitRepos\intersight-rest-api\intersight_auth.py", line 56, in _get_auth_header b64_signed_auth_digest = _get_rsasig_b64(secret_key, string_to_sign.encode()) File "C:\GitRepos\intersight-rest-api\intersight_auth.py", line 47, in _get_rsasig_b64 return b64encode(key.sign( TypeError: sign() takes 3 positional arguments but 4 were given

I'm running Python 3.8.2 on Windows 10.

movinalot commented 4 years ago

@jwomack I was successful running python 3.8.3 and Windows 10

Did you install the python requirements, from the requirements.txt? Did you create your own REST API Key?

I cannot recreate this error

jwomack commented 4 years ago

Yes, I installed the modules from requirements.txt. Yes, I created my own API key.

pip freeze astroid==2.3.3 certifi==2019.11.28 cffi==1.13.2 chardet==3.0.4 colorama==0.4.3 cryptography==2.8 idna==2.8 isort==4.3.21 lazy-object-proxy==1.4.3 mccabe==0.6.1 pycparser==2.19 pylint==2.4.4 requests==2.22.0 six==1.13.0 typed-ast==1.4.0 urllib3==1.25.7 wrapt==1.11.2

jwomack commented 4 years ago

So I went back through and recreated the API key because it was for a different account that we have since deleted. The modules from requirements.txt may not have been there when I originally did the test, but they definitely are now. I think the original error may be from a failed authentication.

>python intersight_ops.py GET <Response [401]>

jwomack commented 4 years ago

Intersting...When I re-created the API key, it is label "Legacy Python SDK". I remember when I did the first API key generation, I was asked if I wanted the "current" (I forget what they called it) or "Legacy Python SDK". This time, the prompts were for "API key for OpenAPI schema version 2" and "API key for OpenAPI schema version 3 (This is a feature in preview and for SDK developer use only)". I suspect they changed their wording and that I had a version 3 API key that was not ready for prime time.