{"id":23472809,"url":"https://github.com/ferryops/djangorestframework-simplejwt","last_synced_at":"2025-07-07T11:07:34.082Z","repository":{"id":269349214,"uuid":"907132511","full_name":"ferryops/djangorestframework-simplejwt","owner":"ferryops","description":"This project is a Django-based API that uses `djangorestframework-simplejwt` for JSON Web Token (JWT) authentication. The configuration sets the access token expiration to 24 hours. The project includes user registration, login, and user profile endpoints.","archived":false,"fork":false,"pushed_at":"2024-12-22T22:52:02.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T08:55:19.173Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ferryops.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-22T22:31:43.000Z","updated_at":"2024-12-22T22:52:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc391ff3-3170-40c0-900f-180ecfb3cb10","html_url":"https://github.com/ferryops/djangorestframework-simplejwt","commit_stats":null,"previous_names":["ferryops/djangorestframework-simplejwt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ferryops/djangorestframework-simplejwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferryops%2Fdjangorestframework-simplejwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferryops%2Fdjangorestframework-simplejwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferryops%2Fdjangorestframework-simplejwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferryops%2Fdjangorestframework-simplejwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ferryops","download_url":"https://codeload.github.com/ferryops/djangorestframework-simplejwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferryops%2Fdjangorestframework-simplejwt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264067137,"owners_count":23552150,"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":[],"created_at":"2024-12-24T17:14:08.328Z","updated_at":"2025-07-07T11:07:34.071Z","avatar_url":"https://github.com/ferryops.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django JWT Authentication Project\n\nThis project is a Django-based API that uses `djangorestframework-simplejwt` for JSON Web Token (JWT) authentication. The configuration sets the access token expiration to 24 hours. The project includes user registration, login, and user profile endpoints.\n\n## Features\n\n- Secure user authentication with JWT.\n- 24-hour expiration for access tokens.\n- Refresh tokens for prolonged access.\n- Easy integration with Django Rest Framework (DRF).\n- User registration and login endpoints.\n- User profile endpoint for retrieving user information.\n- Custom user model for user management.\n\n## Installation\n\n### 1. Clone the Repository\n\n```bash\ngit clone https://github.com/ferryops/djangorestframework-simplejwt.git\ncd djangorestframework-simplejwt\n```\n\n### 2. Create a Virtual Environment\n\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: .\\venv\\Scripts\\activate\n```\n\n### 3. Install Dependencies\n\n```bash\npip install -r requirements.txt\n```\n\n### 4. Apply Migrations\n\n```bash\npython manage.py migrate\n```\n\n### 5. Run the Development Server\n\n```bash\npython manage.py runserver\n```\n\n## Configuration\n\n### JWT Settings\n\nThe JWT settings are configured in `settings.py` using the `djangorestframework-simplejwt` library. The access token expiration is set to 24 hours:\n\n```python\nSIMPLE_JWT = {\n    'ACCESS_TOKEN_LIFETIME': timedelta(hours=24),\n    'REFRESH_TOKEN_LIFETIME': timedelta(days=7),\n    'ROTATE_REFRESH_TOKENS': False,\n    'BLACKLIST_AFTER_ROTATION': True,\n    'ALGORITHM': 'HS256',\n    'SIGNING_KEY': 'your-secret-key',\n}\n```\n\n### Authentication Classes\n\nEnsure `JWTAuthentication` is added to the default authentication classes:\n\n```python\nREST_FRAMEWORK = {\n    'DEFAULT_AUTHENTICATION_CLASSES': (\n        'rest_framework_simplejwt.authentication.JWTAuthentication',\n    ),\n}\n```\n\n## Endpoints\n\n### Token Endpoints\n\n| Endpoint              | Method | Description                      |\n| --------------------- | ------ | -------------------------------- |\n| `/api/token/`         | POST   | Obtain access and refresh tokens |\n| `/api/token/refresh/` | POST   | Refresh the access token         |\n\n#### Example Request to Obtain Tokens\n\n```bash\nPOST /api/token/\n{\n    \"username\": \"your_username\",\n    \"password\": \"your_password\"\n}\n```\n\n#### Example Response\n\n```json\n{\n  \"access\": \"\u003cjwt-access-token\u003e\",\n  \"refresh\": \"\u003cjwt-refresh-token\u003e\"\n}\n```\n\n## Postman Collection\n\nA Postman collection is provided in the repository to help you test the API endpoints. Import the collection into Postman to interact with the API.\n\n[Django REST postman collection](https://github.com/ferryops/djangorestframework-simplejwt/blob/main/Django%20REST.postman_collection.json)\n\n## Testing\n\nTo verify the expiration and functionality of tokens, use tools like Postman or curl to interact with the API. You can also decode the JWT using [jwt.io](https://jwt.io) to check the `exp` field.\n\n## Dependencies\n\n- asgiref==3.8.1\n- Django==5.1.4\n- django-cors-headers==4.6.0\n- djangorestframework==3.15.2\n- djangorestframework-simplejwt==5.3.1\n- PyJWT==2.10.1\n- sqlparse==0.5.3\n\n## Contributing\n\nFeel free to submit issues or pull requests for improvements or bug fixes.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferryops%2Fdjangorestframework-simplejwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fferryops%2Fdjangorestframework-simplejwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferryops%2Fdjangorestframework-simplejwt/lists"}