Skip to content

box-community/box-python-oauth-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

“box-dev-logo”

Sample application using the Box Python SDK and oAuth 2.0

This application is a template to get you started quickly with the Box Python SDK and oAuth 2.0.

Box configuration steps

  1. Create a Box free account if you don't already have one.
  2. Complete the registration process by verifying your email and login to Box.
  3. Making sure you're logged in navigate to the Box Developer Console. This will activate your developer account.
  4. Create a new Box application. Select Custom App, fill in the form and then click Next.
  5. Select User Authentication (OAuth 2.0) and then click Create App.
  6. Scroll down to Redirect URIs and add the following redirect URI:
  7. Check all boxes in application scopes.
    • (or only what you think will be necessary)
  8. Click Save Changes.
  9. Note the Client ID and Client Secret. You will need these later.

Installation and configuration

You will need to have python installed on your machine.

Get the code

git clone [email protected]:barduinor/box-python-oauth-template.git
cd box-python-oauth-template

Set up your virtual environment

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Create your local application environment file

cp .env.sample .env

Open the code in the code editor of your choice.

code .

Update the CLIENT_ID and CLIENT_SECRET field values in the env file with the Box application client id and client secret you created on the developer console.

Run the application

python main.py

The first time you run the application, it should open a web browser window and prompt you to log in to Box. After you log in, it will ask you to authorize the application. Once this process is complete you can close the browser window. By default the sample app prints the current user's name to the console, and lists the items on the root folder.

The authorization token lasts for 60 minutes, and the refresh token for 60 days. If you get stuck, you can delete the .outh.json file and reauthorize the application.

Questions

If you get stuck or have questions, make sure to ask on our Box Developer Forum

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages