···11+MIT License
22+33+Copyright (c) 2025 Nick Gerakines
44+55+Permission is hereby granted, free of charge, to any person obtaining a copy
66+of this software and associated documentation files (the "Software"), to deal
77+in the Software without restriction, including without limitation the rights
88+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
99+copies of the Software, and to permit persons to whom the Software is
1010+furnished to do so, subject to the following conditions:
1111+1212+The above copyright notice and this permission notice shall be included in all
1313+copies or substantial portions of the Software.
1414+1515+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1717+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121+SOFTWARE.
+72
README.md
···11+# OAuth Masterclass Python
22+33+A Flask application demonstrating ATProtocol OAuth with DPoP (Demonstrating Proof-of-Possession) and PKCE (Proof Key for Code Exchange).
44+55+Part of the **OAuth Masterclass** by [Nick Gerakines](https://github.com/ngerakines).
66+77+## Prerequisites
88+99+- Python 3.7 or higher
1010+- pip
1111+1212+## Setup and Installation
1313+1414+1. Create a virtual environment:
1515+```bash
1616+python -m venv venv
1717+```
1818+1919+2. Activate the virtual environment:
2020+```bash
2121+# On macOS/Linux:
2222+source venv/bin/activate
2323+2424+# On Windows:
2525+venv\Scripts\activate
2626+```
2727+2828+3. Install dependencies:
2929+```bash
3030+pip install flask requests pyjwt cryptography dnspython
3131+```
3232+3333+## Running the Application
3434+3535+1. Ensure your virtual environment is activated (see step 2 above)
3636+3737+2. Run the Flask application:
3838+```bash
3939+python app.py
4040+```
4141+4242+3. The application will start on port 5000. Access it at:
4343+ - Local development: `http://localhost:5000`
4444+ - Production: `https://oauth-py.smokesignal.tools`
4545+4646+## Features
4747+4848+- ATProtocol OAuth authentication
4949+- DPoP token binding
5050+- PKCE for enhanced security
5151+- Handle resolution with HTTP fallback to DNS (following ATProtocol specification)
5252+- DID document resolution (did:plc and did:web)
5353+- Token refresh handling
5454+- Protected routes with automatic token refresh
5555+5656+## Deactivating the Virtual Environment
5757+5858+When you're done, deactivate the virtual environment:
5959+```bash
6060+deactivate
6161+```
6262+6363+# Demo
6464+6565+1. Start the application
6666+2. Start the proxy
6767+3. Visit https://oauth-py.smokesignal.tools/
6868+4. Example records at https://pdsls.dev/at://did:plc:cbkjy5n7bk3ax2wplmtjofq2/garden.lexicon.oauth-masterclass.now
6969+7070+## License
7171+7272+This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.