Skip to main content

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/ .


Thanks - I knew there was an easy solution.  Quotes solved it.  

 

 


Hi - may I ask where those quotes went? 

 

I just ran into this errror, too, trying to wrap my head around JWTAuth and basically following what I found here in this thread.

 

 

Cheers,

Andrej


I ran into the same issue and it ended up being the cryptography install was missing. I ran this install  

sudo yum install gcc libffi-devel python-devel openssl-devel

then ran this:

sudo pip install "boxsdk[jwt]"

and it worked.  


After these instructions I get a:

ValueError: Could not unserialize key data.

 I am running Python 2.7


Try my answer found here:

 

https://community.box.com/t5/Platform-and-Development-Forum/Authentication-Using-JWT-in-Python-quot-Nonetype-quot-issue/m-p/55531/highlight/false#M4559

 

you may have the wrong JWT package if you are using python 2.7


Any thoughts on getting this to work in 2020?