{"id":27599634,"url":"https://github.com/clerk/django-drf-example","last_synced_at":"2026-04-13T21:32:36.768Z","repository":{"id":288348709,"uuid":"966852563","full_name":"clerk/django-drf-example","owner":"clerk","description":"Django DRF Clerk Auth Example","archived":false,"fork":false,"pushed_at":"2025-04-15T14:51:12.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-29T06:56:14.646Z","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/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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-15T14:50:47.000Z","updated_at":"2025-06-19T19:36:47.000Z","dependencies_parsed_at":"2025-04-22T15:42:00.864Z","dependency_job_id":null,"html_url":"https://github.com/clerk/django-drf-example","commit_stats":null,"previous_names":["clerk/django-drf-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clerk/django-drf-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-drf-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-drf-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-drf-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-drf-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clerk","download_url":"https://codeload.github.com/clerk/django-drf-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fdjango-drf-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31771832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T20:17:16.280Z","status":"ssl_error","status_checked_at":"2026-04-13T20:17:08.216Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-04-22T15:39:55.263Z","updated_at":"2026-04-13T21:32:36.757Z","avatar_url":"https://github.com/clerk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django DRF 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 DRF 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\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-drf-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclerk%2Fdjango-drf-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclerk%2Fdjango-drf-example/lists"}