Box Python-SDK oauth error

Hi, I am very new to using python. I tried to follow documentation of python SDK. I want to use GET / POST requests on box via python.

  1. I am using OAUTH, is it alright? (Or should I use basic auth / JWT - I am unaware of these methods but willing to learn)

  2. Here is the process I followed :
    a) Created a new app in Box Developers with Oauth. I am able to use this clientID & clientSECRET in postman app to fire all API commands. I have generated “Developer Token” as well on this page.

b) Downloaded boxsdk to use it in python environment

Please tell me what I am doing wrong.
What should I use as Auth Code, if not the developer token? How to generate this auth code? Is my redirect URL Correct?

PLEASE HELP!!!

Hi @rahuldesai , welcome to the forum.

Perhaps you should try a CCG authentication for your Python script.

OAuth 2.0 is interactive and requires user interventions.

Looking at your code, after doing the oauth.get_authorization_url you are supposed to redirect the user browser for them to authorize the app. This might not be practical in your situation.

However I do have some authentication examples to share with you.

For the classic Box Python SDK you can take a look at this GitHub repo, specifically the test_ccg.py, test_jwt.py, and test_oauth.py. These samples are a bit old but they should work, check the requirements.txt for specific versions.

For the Next Gen Box Python SDK, you can look here. Same pattern, take a look at the test_xxx.py scripts.

These are also workshops, see if there is a topic you would like to explore.

Let us know if this helps

Best regards