{"id":26462932,"url":"https://github.com/clerk/django-example","last_synced_at":"2025-07-30T05:32:53.447Z","repository":{"id":104053491,"uuid":"467319022","full_name":"clerk/django-example","owner":"clerk","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-15T14:42:33.000Z","size":22,"stargazers_count":9,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T15:43:09.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"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/clerk.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}},"created_at":"2022-03-08T01:25:02.000Z","updated_at":"2025-04-15T14:42:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e38a3bbc-e209-4850-ae9e-fb5e1746fc29","html_url":"https://github.com/clerk/django-example","commit_stats":null,"previous_names":["clerk/django-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clerk/django-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clerk","download_url":"https://codeload.github.com/clerk/django-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815187,"owners_count":24148356,"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-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2025-03-19T06:26:18.998Z","updated_at":"2025-07-30T05:32:53.414Z","avatar_url":"https://github.com/clerk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Clerk Auth Example\n\nA demonstration of using Clerk JWT authentication with Django. This example shows how to integrate Clerk's user authentication with a Django backend API.\n\n## Configuration\n\nSet the required environment variables:\n\n```bash\n$ export CLERK_API_SECRET_KEY=your_secret_key\n\n# Set authorized parties (comma-separated list of allowed origins)\n$ export CLERK_AUTHORIZED_PARTIES=http://localhost:5173\n```\n\n## Installation \n\n```commandline\npython -m venv venv\nsource venv/bin/activate\npip install -r requirements.txt\n```\n\n## Running \n\n```commandline\npython manage.py runserver\n```\n\nThe server will be running at `http://localhost:8000`.\n\n## Frontend Integration\n\nFrom a Clerk React frontend:\n\n```javascript\nimport { useAuth } from '@clerk/clerk-react';\n\nfunction ApiExample() {\n  const { getToken } = useAuth();\n  \n  const fetchData = async () =\u003e {\n    if (getToken) {\n      // Get the userId or null if the token is invalid\n      let res = await fetch(\"http://localhost:8000/clerk_jwt\", {\n          headers: {\n              \"Authorization\": `Bearer ${await getToken()}`\n          }\n      });\n      console.log(await res.json()); // {userId: 'the_user_id_or_null'}\n\n      // Get gated data or a 401 Unauthorized if the token is not valid\n      res = await fetch(\"http://localhost:8000/gated_data\", {\n          headers: {\n              \"Authorization\": `Bearer ${await getToken()}`\n          }\n      });\n      if (res.ok) {\n          console.log(await res.json()); // {foo: \"bar\"}\n      } else {\n          // Token was invalid\n      }\n    }\n  };\n  \n  return \u003cbutton onClick={fetchData}\u003eFetch Data\u003c/button\u003e;\n}\n```\n\n## API Reference\n\nAvailable endpoints:\n\n- `GET /clerk_jwt` - Returns the authenticated user ID\n- `GET /gated_data` - Returns protected data (requires authentication)\n\n\n## ⚠️ Production Warning\n\nThis project is not optimized for production and does not address all best practices that should be configured in a production app. It serves as a design template and should be given appropriate consideration before being used in production.\n\nIssues to address for production use:\n- CORS configuration is specific to development environments\n- No HTTPS enforcement\n- Minimal error handling (especially 401 errors)\n- Using development server settings\n\nFor production deployment:\n1. Configure proper CORS settings for your specific domains\n2. Enforce HTTPS for all API communication\n3. Implement comprehensive error handling\n4. Use a production-grade web server instead of the built-in development server","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclerk%2Fdjango-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclerk%2Fdjango-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclerk%2Fdjango-example/lists"}