JWT Oath using python
回答済みThis is a pretty straightforward question I am hoping someone can help explain. There might be some knowledge gaps - so forgive any glaring gaps in advance.
In the boxsdk repo they give a quick example how to set up boxsdk with JWT OAth. (https://github.com/box/box-python-sdk)
They provide the following code:
pip install boxsdk[jwt]
However - this pip install doesn't work as a result of the square brackets.
Question: What are the square brackets around the jwt indicative of and why might it not install on my local?
The standard installation with underlying repositories seems to work however when I run the code to instantiate the JWTAuth class....
from boxsdk import JWTAuthauth = JWTAuth(client_id='XXXX',client_secret='XXX',enterprise_id=12345,jwt_key_id='XXXX',rsa_private_key_file_sys_path='/path/CERT.PEM',)
I get a ...
TypeError: 'NoneType' object is not callable
Which leads me to believe that the
pip install boxsdk[jwt]
is relevant to the issue at hand as I couldn't find a culprit in my call or in the code in the sdk.
Any help much appreciated - thanks all
-
The square brackets indicates installing an "extra".
In our setup.py (https://github.com/box/box-python-sdk/blob/master/setup.py) file, you'll see this:
extra_requires = defaultdict(list) extra_requires.update({'jwt': jwt_requires, 'redis': redis_requires, 'all': jwt_requires + redis_requires}) setup( ... extras_require=extra_requires, ... )
The 'jwt' dependencies aren't required to use the SDK, but they are required to use the JWT features of the SDK. pip install boxsdk[jwt] says to install boxsdk, its dependencies, AND the extra 'jwt' dependencies.
I'm not sure why this isn't working for you, but here's three ideas:
In case your terminal is trying to do something special with the square brackets, try surrounding the last part in quotes: pip install "boxsdk[jwt]"
Or perhaps your versions of wheel, setuptools, and pip are too old. Inside your virtualenv, run
python -m pip install -U wheel python -m pip install -U setuptools python -m pip install -U pip
Finally, if it still doesn't work, you can install the dependencies by hand: pip install boxsdk 'pyjwt>=1.3.0' 'cryptography>=0.9.2'
And if installing cryptography gives you problems, see https://cryptography.io/en/latest/installation/ .
-
Try my answer found here:
you may have the wrong JWT package if you are using python 2.7
サインインしてコメントを残してください。
コメント
7件のコメント