新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

Authentication Using JWT in Python "Nonetype" issue

回答済み
新規投稿

コメント

8件のコメント

  • jcleblanc

    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

    0
    コメントアクション Permalink
  • zperis

    I had already pip installed box[sdk]

    Perhaps my pem file is wrong? 

    How do you make a pem file from the json downloaded from a box generated private key? 

    What is with all the newline characters?

     

    I'm on MacOs Sierra 10.12.5 

    0
    コメントアクション Permalink
  • jcleblanc

    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

     

     

    0
    コメントアクション Permalink
  • mmorleydesign

    I followed your instructions and now get a :

    ValueError: Could not unserialize key data.

    I am running Python 2.7.

     

     

    0
    コメントアクション Permalink
  • jwsynthego

    I am having the same problem. Is it the new lines that are throwing off the cryptography function load_pem_data()?

    0
    コメントアクション Permalink
  • rsabi

    If you still have the same issue and you are using python 2.7, make sure to install PyJWT package for python 2.x instead of JWT for 3.x, so, uninstall jwt if you already have it, and install pyjwt.

     

    pip uninstall jwt

    then 

    pip install pyjwt

     

    0
    コメントアクション Permalink
  • roncraig007

    Yup.  I had to literally run

    pip install boxsdk[jwt]

    Then most requirements were already met since I'd installed boxsdk, but additional things were then installed.

    After that, the error went away.

    0
    コメントアクション Permalink
  • Sebastian Zepp Schult (ISPD)

    Still getting this..... ;(

    Class 'JWTAuth' does not define '__getitem__', so the '[]' operator cannot be used on its instances

    appAuth = config["boxAppSettings"]["appAuth"]
    TypeError: 'JWTAuth' object is not subscriptable

    1
    コメントアクション Permalink

サインインしてコメントを残してください。