{"id":27599629,"url":"https://github.com/clerk/springboot-example","last_synced_at":"2025-07-20T12:33:57.216Z","repository":{"id":288348712,"uuid":"966857654","full_name":"clerk/springboot-example","owner":"clerk","description":"Spring boot Clerk auth example","archived":false,"fork":false,"pushed_at":"2025-06-12T13:40:24.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-05T09:04:43.682Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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:58:55.000Z","updated_at":"2025-06-12T13:40:28.000Z","dependencies_parsed_at":"2025-04-20T06:47:00.796Z","dependency_job_id":null,"html_url":"https://github.com/clerk/springboot-example","commit_stats":null,"previous_names":["clerk/springboot-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clerk/springboot-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fspringboot-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fspringboot-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fspringboot-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fspringboot-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clerk","download_url":"https://codeload.github.com/clerk/springboot-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clerk%2Fspringboot-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266127213,"owners_count":23880421,"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":"2025-04-22T15:39:47.530Z","updated_at":"2025-07-20T12:33:57.178Z","avatar_url":"https://github.com/clerk.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring boot Clerk auth example\n\nA demonstration of using Clerk JWT authentication with Spring boot. This example shows how to integrate Clerk's user authentication with a Spring boot 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\nmvn clean install\n ```\n\n## Running\n\n```commandline\nmvn spring-boot:run\n```\n\nThe server will be running at `http://localhost:8080`.\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:8080/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:8080/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%2Fspringboot-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclerk%2Fspringboot-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclerk%2Fspringboot-example/lists"}