OAuth Masterclass Python#
A Flask application demonstrating ATProtocol OAuth with DPoP (Demonstrating Proof-of-Possession) and PKCE (Proof Key for Code Exchange).
Part of the OAuth Masterclass by Nick Gerakines.
Prerequisites#
- Python 3.7 or higher
- pip
Setup and Installation#
- Create a virtual environment:
python -m venv venv
- Activate the virtual environment:
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate
- Install dependencies:
pip install flask requests pyjwt cryptography dnspython
Running the Application#
-
Ensure your virtual environment is activated (see step 2 above)
-
Run the Flask application:
python app.py
- The application will start on port 5000. Access it at:
- Local development:
http://localhost:5000 - Production:
https://oauth-py.smokesignal.tools
- Local development:
Features#
- ATProtocol OAuth authentication
- DPoP token binding
- PKCE for enhanced security
- Handle resolution with HTTP fallback to DNS (following ATProtocol specification)
- DID document resolution (did:plc and did:web)
- Token refresh handling
- Protected routes with automatic token refresh
Deactivating the Virtual Environment#
When you're done, deactivate the virtual environment:
deactivate
Demo#
- Start the application
- Start the proxy
- Visit https://oauth-py.smokesignal.tools/
- Example records at https://pdsls.dev/at://did:plc:cbkjy5n7bk3ax2wplmtjofq2/garden.lexicon.oauth-masterclass.now
License#
This project is licensed under the MIT License - see the LICENSE file for details.