{"id":21888347,"url":"https://github.com/martincantillo/flask-jwt","last_synced_at":"2026-04-11T22:03:28.686Z","repository":{"id":211187501,"uuid":"728406353","full_name":"MartinCantillo/Flask-jwt","owner":"MartinCantillo","description":"API with  Flask-JWT-Extended ","archived":false,"fork":false,"pushed_at":"2023-12-08T03:08:06.000Z","size":14583,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T20:31:58.034Z","etag":null,"topics":["flask","flask-jwt-extended","flask-sqlalchemy","jwt","marshmallow-sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MartinCantillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-06T21:53:08.000Z","updated_at":"2024-03-17T20:15:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"f6d3003c-d061-41c2-8459-da39aa71fbc5","html_url":"https://github.com/MartinCantillo/Flask-jwt","commit_stats":null,"previous_names":["martincantillo/flask-jwt","cantillomartin/flask-jwt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinCantillo%2FFlask-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinCantillo%2FFlask-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinCantillo%2FFlask-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MartinCantillo%2FFlask-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MartinCantillo","download_url":"https://codeload.github.com/MartinCantillo/Flask-jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244895433,"owners_count":20527887,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-jwt-extended","flask-sqlalchemy","jwt","marshmallow-sqlalchemy"],"created_at":"2024-11-28T11:15:01.010Z","updated_at":"2026-04-11T22:03:28.638Z","avatar_url":"https://github.com/MartinCantillo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-JWT-Extended\n\n![Flask](https://img.shields.io/badge/Flask-3.0.0-blue?logo=flask)\n![Python](https://img.shields.io/badge/Python-3.x-blue?logo=python)\n![JWT](https://img.shields.io/badge/JWT-JSON%20Web%20Token-green?logo=json-web-tokens)\n\n## Description\n\nThis project demonstrates a simple implementation of JWT (JSON Web Token) authentication using Flask and Flask-JWT-Extended. It includes user authentication, token generation, and protected routes.\n\n## Prerequisites\n\n- Python 3.x\n- Flask 3.0.0 ![Flask](https://img.shields.io/badge/Flask-3.0.0-blue?logo=flask)\n- Flask-JWT-Extended 4.5.3 ![JWT](https://img.shields.io/badge/JWT-4.5.3-green?logo=json-web-tokens)\n- Flask-SQLAlchemy\n- Flask-Marshmallow\n- MySQL database\n\n## Installation\n\n1. Clone the repository:\n\n    ```bash\n    git clone https://github.com/MartinCantillo/Flask-jwt \n    ```\n\n2. Install dependencies:\n\n    ```bash\n    pip install -r requirements.txt\n    ```\n\n3. Set up the MySQL database. Update the `app.config['SQLALCHEMY_DATABASE_URI']` in `app.py` with your database connection details.\n\n4. Run the application:\n\n    ```bash\n    python app.py\n    ```\n\n## Configuration\n\n- **MySQL Database:** Update the `app.config['SQLALCHEMY_DATABASE_URI']` in `app.py` with your database connection details.\n\n- **JWT Configuration:** Update the `app.config[\"JWT_SECRET_KEY\"]` in `app.py` with a secure secret key.\n\n## Usage\n\n1. **Login without Cookies:**\n\n    ```bash\n    POST /login_without_cookies\n    ```\n\n    Authenticate and receive a JWT token.\n\n2. **Login with Cookies:**\n\n    ```bash\n    POST /login_with_cookies\n    ```\n\n    Authenticate and receive a JWT token, which is also stored in the cookies.\n\n3. **Logout with Cookies:**\n\n    ```bash\n    POST /logout_with_cookies\n    ```\n\n    Log out and remove the JWT token from cookies.\n\n4. **Protected Route:**\n\n    ```bash\n    GET /protected\n    ```\n\n    Access a protected route by providing a valid JWT token (can be in headers, cookies, JSON, or query string).\n\n5. **Protected Route with Headers:**\n\n    ```bash\n    GET /only_headers\n    ```\n\n    Access a protected route by providing a valid JWT token only in headers.\n\n## Models\n\n- **Role Model:**\n\n    - `id_rol`: Integer, primary key\n    - `nombre_rol`: String(50)\n\n- **User Model:**\n\n    - `id`: Integer, primary key\n    - `username`: Text, unique\n    - `full_name`: String(50)\n    - `password`: String(50)\n    - `rol_id`: Integer, foreign key referencing `tblRol.id_rol`\n\n## Schemas\n\n- **Role Schema:**\n\n    - `id_rol`\n    - `nombre_rol`\n\n- **User Schema:**\n\n    - `id`\n    - `username`\n    - `full_name`\n    - `password`\n    - `rol_id`\n    - `rol`\n\n## Routes\n\n- `/login_without_cookies`: Authenticate without storing the token in cookies.\n- `/login_with_cookies`: Authenticate and store the token in cookies.\n- `/logout_with_cookies`: Log out and remove the token from cookies.\n- `/protected`: Access a protected route (token can be in headers, cookies, JSON, or query string).\n- `/only_headers`: Access a protected route with the token only in headers.\n\n## Additional Notes\n\n- Ensure that your MySQL server is running and the database is created.\n\n- Customize the JWT secret key and database URI according to your security requirements.\n\n- This project is intended as a basic demonstration and may need further enhancements for a production environment.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartincantillo%2Fflask-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmartincantillo%2Fflask-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmartincantillo%2Fflask-jwt/lists"}