Welcome to the new Box Support website. Check out all the details here on what’s changed.

boxsdk.exception.BoxOAuthException forJWT authorization Python

New post

Comments

7 comments

  • sachinshinde1

    Did you have an update on this error? Solution? I am getting the same error. 

    0
    Comment actions Permalink
  • kraffy

    I too am receiving the same exact error

    0
    Comment actions Permalink
  • velociraptor2

    I too am receiving the same exact error.

    0
    Comment actions Permalink
  • northwestern

    I am also receiving this error, although I'm doing regular Oauth verification, not using JWT. 

    0
    Comment actions Permalink
  • jcleblanc

    Hi all, 

     

    For anyone still experiencing this issue, it was discussed and solved (in one instance) in the Python SDK Github repo.  

     

    In short, here are some of the main reasons that this might be occurring: 

     

    Incorrect client ID / secret

    Ensure that you are using the correct client ID and secret for the application. These can be found in the developer console by going to your app then clicking on the configuration section in the left hand nav.

     

    Incorrectly formatted public key

    The public key that you uploaded in the developer console is improperly formatted. The correct format looks like this:

    -----BEGIN PUBLIC KEY-----
    //PUBLIC KEY INFO
    -----END PUBLIC KEY-----

     Thanks all,

    Jon

    0
    Comment actions Permalink
  • mikeporterinmd

    If you use the new JSON download option in your application setup, the JWTAuth code turns into:

     

    with open( json_file_path ) as f:
        lp = json.load( f )

     

    lp_s = lp[ 'boxAppSettings' ]
    lp_s_a = lp_s[ 'appAuth' ]

     

    auth = boxsdk.JWTAuth(
        enterprise_id = lp[ 'enterpriseID' ],

        client_id = lp_s[ 'clientID' ],
        client_secret = lp_s[ 'clientSecret' ],
        rsa_private_key_data = bytes( lp_s_a['privateKey'], 'ascii' ),
        rsa_private_key_passphrase = bytes( lp_s_a[ 'passphrase' ], 'ascii' ),
        jwt_key_id = lp_s_a[ 'publicKeyID' ]
    )

    access_token = auth.authenticate_instance()
    client = boxsdk.Client( auth )

    0
    Comment actions Permalink
  • ela3

    I also got the same error. I used the SDK of JWT in Python and I am sure that my admin user has already approved my JWT application. 

     

    The code was: 

     

     

     

    auth = JWTAuth.from_settings_file('/Path_to_file/config.json')
    client = Client(auth) 
    service_account = client.user().get()
    print('Service Account user ID is {0}'.format(service_account.id))

     

     

     
    I used the 'Generate a Public/Private Keypair' in the Developer Console and downloaded the config_json file. 
    The json file looks like: 
     
     

     

     

    {
      "boxAppSettings": {
        "clientID": "............................",
        "clientSecret": "..............................",
        "appAuth": {
          "publicKeyID": "xxxxx",
          "privateKey": "-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIIFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXp\nXJA=\n-----END ENCRYPTED PRIVATE KEY-----\n",
          "passphrase": "XXXXXXXXXXXXXXXX"
        }
      },
      "enterpriseID": "XXXXX"

     

     

     
    But I got the same error message: 
    boxsdk.exception.BoxOAuthException:
    Message: A request parameter was invalid
    Status: 400
    URL: https://api.box.com/oauth2/token
    Method: POST

     

     

     
    Could someone help me with this error message? What should I change or deal with this problem? And    How did you solve this issue? 

    0
    Comment actions Permalink

Please sign in to leave a comment.