Authentication Using JWT in Python "Nonetype" issue
回答済みI am fairly new at box dev and JWT, so I had box generate a keypair for me, but the cert.pem file
is run as a nonetype object. Can someone help me with this error/ how to authenticate using JWT in Python
(I've already used the SDK's instructions)
Here is the error message:
Traceback (most recent call last):
File "/Users/zperis/PycharmProjects/AutoBox/ImportTest.py", line 11, in
rsa_private_key_file_sys_path='/Users/zperis/Documents/cert.pem',
TypeError: 'NoneType' object is not callable
Here is my Source Code:
from boxsdk import JWTAuth
auth = JWTAuth(
client_id='*******',
client_secret='*********',
enterprise_id='*******',
jwt_key_id= '********',
rsa_private_key_file_sys_path='/Users/zperis/Documents/cert.pem',
#store_tokens=your_store_tokens_callback_method,
)
access_token = auth.authenticate_instance()
from boxsdk import Client
client = Client(auth)
-
Hi zperis, this Github issue should help with the problem. The gist from the comment is, "JWTAuth is only defined if its dependencies are available (which you get with pip install boxsdk[jwt])".
I created a quick sample with your code and my own credentials / keys, duplicated the error, then ran pip install boxsdk[jwt] to install the dependency, and that fixed it for me.
Hope that helps,
Jon
-
I'm still digging through for a potential solution to directly answer your question. Right now it looks like the Python SDK doesn't have a direct import for the .json files produced through the app process.
I'll keep looking for a direct solution for that, but in the meantime, let me provide you with an alternative to get you over the hurdle by creating your own keys.
To generate a new public / private key set in a terminal window, just run the following two commands:
openssl genrsa -out private.pem 2048 openssl rsa -in private.pem -outform PEM -pubout -out public.pem
Now you can go to the "Add and Manage Public Keys" section of your app (under "Configuration"), and click "Add a public key". Copy in the contents of public.pem in the box, then click "Verify and Save". You can then change jwt_key_id to the new public key ID, and point rsa_private_key_file_sys_path to where that key is located.
That's the process I followed for my app, but I did have to pip install boxsdk[jwt] specifically to bypass the original error you were getting.
- Jon
サインインしてコメントを残してください。
コメント
8件のコメント