Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

How to completely automate getting the access token and refresh token using OAuth for Python

New post

Comments

2 comments

  • jcleblanc

    Hi ,

     

    You'll want to use the JWT / OAuth2 process instead of just OAuth2 to accomplish this. The JWT piece will replace the need for the user to log in to their Box account and accept the permissions of the application. Instead it's all done seamlessly behind the scenes. 

     

    Here's more on the JWT app setup process: https://developer.box.com/docs/setting-up-a-jwt-app

     

    Here's a walkthrough of getting the access token, including Python samples: https://developer.box.com/docs/authenticate-with-jwt

     

    Hope that helps,

    Jon

    0
    Comment actions Permalink
  • dkadia

    Hi, 

     

    using the resources provided, now i am getting following error. Can you please let me know what i am doing wrong and how to fix it. 

     

    Error - 

    ValueError: Could not deserialize key data.

    Code

    from boxsdk import JWTAuth
    from boxsdk import Client
    
    # Configure JWT auth object
    sdk = JWTAuth(
      client_id="my_client_id",
      client_secret="my_client_Secret",
      enterprise_id="enterprise_Id",
      jwt_key_id="key_id",
     rsa_private_key_file_sys_path = "C:/Users/Downloads/boxAPIAccess.pem",
    rsa_private_key_passphrase = b'pass_phrase'
    )

     

    0
    Comment actions Permalink

Please sign in to leave a comment.