Skip to content

box-community/ui-elements-oauth

Repository files navigation

“box-dev-logo”

Getting started with Box OAuth 2.0 using Python & Flask

This is the companion app to illustrate this medium article. Check it out.

Installation

Get the code

git clone [email protected]:barduinor/ui-elements-oauth.git
cd ui-elements-oauth

Set up your virtual environment

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

Create your application environment

cp .env.example .env

Generate a secret key for your app

python -c "import os; print(os.urandom(24).hex())"

Generate a fernet (encryption) key for your app

python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key())"

Edit your .env file and fill in the information

# True for development, False for production
DEBUG=True

# Flask ENV
FLASK_APP=run.py
FLASK_ENV=development
SECRET_KEY='YOUR_SECRET_KEY'
FERNET_KEY='YOU_ENCRYPTION_KEY'

# Box OAuth
CLIENT_ID='YOUR_CLIENT_ID'
CLIENT_SECRET='YOUR_CLIENT_SECRET'
REDIRECT_URI='http://localhost:5000/oauth/callback'

Update your box application settings in the box developer console Include your redirect URI in the list of allowed redirect URIs

http://localhost:5000/oauth/callback

Include your allowed origins in the CORS Domain section

http://localhost:5000/oauth/callback

Run your server

flask run --host localhost --port 5000

Point your browser to the server (e.g http://localhost:5000). Inspect your browser console to see the javascript events. Server events will be printed on the terminal.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published