{"id":21250917,"url":"https://github.com/natlee/django-allauth-jwt-template","last_synced_at":"2025-07-22T09:31:54.392Z","repository":{"id":252210473,"uuid":"839744651","full_name":"NatLee/django-allauth-JWT-template","owner":"NatLee","description":"Django Allauth搭配JWT使用的範例","archived":false,"fork":false,"pushed_at":"2024-12-24T05:50:35.000Z","size":239,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-11T05:14:35.337Z","etag":null,"topics":["3rd-party-login","authentication-backend","authentication-middleware","backend","django","django-allauth","jwt","jwt-authentication"],"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/NatLee.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-08-08T08:40:35.000Z","updated_at":"2024-12-24T05:50:38.000Z","dependencies_parsed_at":"2024-08-08T11:25:27.191Z","dependency_job_id":"b4d26365-06ce-460a-8c05-6df49712670f","html_url":"https://github.com/NatLee/django-allauth-JWT-template","commit_stats":null,"previous_names":["natlee/django-allauth-jwt-template"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NatLee/django-allauth-JWT-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLee%2Fdjango-allauth-JWT-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLee%2Fdjango-allauth-JWT-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLee%2Fdjango-allauth-JWT-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLee%2Fdjango-allauth-JWT-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NatLee","download_url":"https://codeload.github.com/NatLee/django-allauth-JWT-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NatLee%2Fdjango-allauth-JWT-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266465118,"owners_count":23933068,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["3rd-party-login","authentication-backend","authentication-middleware","backend","django","django-allauth","jwt","jwt-authentication"],"created_at":"2024-11-21T03:39:35.336Z","updated_at":"2025-07-22T09:31:54.126Z","avatar_url":"https://github.com/NatLee.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Allauth JWT Template\r\n\r\n![demo](./doc/dashboard.png)\r\n\r\n\u003e All 3rd party authentication is handled by Django Allauth and they are server side rendered(SSR).\r\n\r\nA Django project template with Django Allauth and JWT authentication.\r\n\r\n## Description\r\n\r\nThis template is for those who want to use JWT for their frontend and backend.\r\n\r\n## Usage\r\n\r\n1. Copy `.env.example` to `.env` and set the environment variables.\r\n\r\n    ```bash\r\n    cd backend \u0026\u0026 cp .env.example .env\r\n    ```\r\n\r\n2. Install requirements.\r\n\r\n    ```bash\r\n    pip install -r requirements.txt\r\n    ```\r\n\r\n3. Migrate and run server.\r\n\r\n    ```bash\r\n    cd backend \u0026\u0026 python manage.py migrate\r\n    ```\r\n\r\n    ```bash\r\n    cd backend \u0026\u0026 python manage.py runserver 0.0.0.0:5566\r\n    ```\r\n\r\n4. Visit `http://localhost:5566`.\r\n\r\n5. (Optional) Create a superuser.\r\n\r\n    ```bash\r\n    python manage.py createsuperuser\r\n    ```\r\n\r\n6. (Optional) Visit `http://localhost:5566/admin` to see the users.\r\n\r\n7. (Optional) When login with `superuser`, you can visit `http://localhost:5566/api/__hidden_swagger` to see the API documentation.\r\n\r\n\r\n## Key Points\r\n\r\n- Allauth Login Login\r\n    [./backend/authentication/adapter.py](./backend/authentication/adapter.py).\r\n\r\n- JWT API\r\n    [./backend/custom_jwt/views.py](./backend/custom_jwt/views.py).\r\n\r\n- Frontend Login\r\n    - HTML\r\n        [./backend/dashboard/templates/index.html](./backend/dashboard/templates/index.html).\r\n    - JavaScript\r\n        [./backend/dashboard/static/js/dashboard.js](./backend/dashboard/static/js/dashboard.js).\r\n\r\n- Frontend 3rd Party Login Routes\r\n\r\n    In this template, I only use `Google`, `Microsoft`, and `Line` as the 3rd party login. You can check the provided in `INSTALLED_APPS` of [./backend/backend/settings.py](./backend/backend/settings.py).\r\n\r\n    The routes are defined in `django-allauth` and you can find the main pattern in [./backend/authentication/urls.py](./backend/authentication/urls.py).\r\n\r\n    In the frontend, you can use the following code to login with 3rd party.\r\n\r\n    ```html\r\n    \u003c!-- ./backend/dashboard/templates/index.html --\u003e\r\n    \u003cdiv id=\"loginButtons\"\u003e\r\n        \u003ca title=\"Google\" href=\"/api/allauth/google/login/?process=login\" class=\"social-login-btn\"\u003e登入 Google\u003c/a\u003e\r\n        \u003ca title=\"Google\" href=\"/api/allauth/google/login/?process=connect\" class=\"social-login-btn\"\u003e綁定 Google\u003c/a\u003e\r\n        \u003ca title=\"Microsoft\" href=\"/api/allauth/microsoft/login/?process=login\" class=\"social-login-btn\"\u003e登入 Microsoft\u003c/a\u003e\r\n        \u003ca title=\"Microsoft\" href=\"/api/allauth/microsoft/login/?process=connect\" class=\"social-login-btn\"\u003e綁定 Microsoft\u003c/a\u003e\r\n        \u003ca title=\"Line\" href=\"/api/allauth/line/login/?process=login\" class=\"social-login-btn\"\u003e登入 Line\u003c/a\u003e\r\n        \u003ca title=\"Line\" href=\"/api/allauth/line/login/?process=connect\" class=\"social-login-btn\"\u003e綁定 Line\u003c/a\u003e\r\n    \u003c/div\u003e\r\n    ```\r\n\r\n## Misc\r\n\r\nI added a file named `./backend/templates/account/messages/logged_in.txt` to avoid login success message in `Admin` login panel.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatlee%2Fdjango-allauth-jwt-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnatlee%2Fdjango-allauth-jwt-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnatlee%2Fdjango-allauth-jwt-template/lists"}