This project contains a Python script that generates a JSON Web Token (JWT) using PyJWT and then updates a record in a SQL Server database using pyodbc. It provides a simple, OAuth-free method for obtaining an API authorization token.
- Python 3.x (Download from python.org/downloads)
- SQL Server with the necessary access (e.g., SQLEXPRESS)
- ODBC Driver for SQL Server (e.g., ODBC Driver 17 for SQL Server or ODBC Driver 18)
Follow these commands in your terminal to set up your Python environment:
-
Upgrade pip:
python -m pip install --upgrade pip
-
Install required Python packages:
pip install PyJWT pip install pyodbc
Before running the script, you may need to modify a few configuration settings in Generate_JWT.py for your environment:
Replace the secret key with your own secure value:
SECRET_KEY = "Password123!" # Replace with your secure secret key.- Environment Changes:
In a new environment, remember to update the following:- The
SECRET_KEYto your new secure value. - The
SQL_CONNECTION_STRINGto match your new SQL Server instance and database. - The database update query if your table structure is different.
- The
- Running the Script:
Runpython Generate_JWT.pyafter making these changes.