{"id":27977347,"url":"https://github.com/coderhs/rails-api-only-devise-jwt-example-app","last_synced_at":"2025-05-08T01:48:28.331Z","repository":{"id":287130763,"uuid":"963360687","full_name":"coderhs/rails-api-only-devise-jwt-example-app","owner":"coderhs","description":"Example Rails 8 App Only app that uses Devise JWT for authentication ","archived":false,"fork":false,"pushed_at":"2025-04-21T23:14:22.000Z","size":52,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T01:48:24.659Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/coderhs.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}},"created_at":"2025-04-09T15:02:30.000Z","updated_at":"2025-04-10T18:55:10.000Z","dependencies_parsed_at":"2025-04-10T05:38:15.052Z","dependency_job_id":"c6c92f24-61d8-47fb-af25-2e9448a3a5c9","html_url":"https://github.com/coderhs/rails-api-only-devise-jwt-example-app","commit_stats":null,"previous_names":["coderhs/rails-api-only-devise-jwt-example-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Frails-api-only-devise-jwt-example-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Frails-api-only-devise-jwt-example-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Frails-api-only-devise-jwt-example-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderhs%2Frails-api-only-devise-jwt-example-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderhs","download_url":"https://codeload.github.com/coderhs/rails-api-only-devise-jwt-example-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252983735,"owners_count":21835762,"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-05-08T01:48:27.724Z","updated_at":"2025-05-08T01:48:28.298Z","avatar_url":"https://github.com/coderhs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example App: Rails 8 in API Only Mode, with Devise JWT for authentication\n\nThis is an example of a Rails 8 API-only app that uses Devise JWT for authentication.\n\n# How to get started\n\n```sh\ngit clone git@github.com:coderhs/rails-api-only-devise-jwt-example-app.git\n```\n\nCreate the `credentials.yml.enc` file:\n\n```sh\nEDITOR=\"vim\" rails credentials:edit\n```\n\nCopy the contents from c`redentials.example.yml` into your new file:\n\n```yml\nsecret_key_base:\ndevise:\n  jwt_secret_key:\n```\n\nFill in both fields with secret tokens, which you can generate using the command `rails secret`\n\nSave and close vim\n\n\n## API end point / testing\n\n### Register a User\n\n```sh\ncurl -i -X POST http://localhost:3000/signup \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"user\": {\"email\": \"test@example.com\", \"password\": \"password\"}}'\n```\n\nYou will receive the JWT token in the response.\n\n\n### Log in a User\n\n```sh\ncurl -i -X POST http://localhost:3000/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"user\": {\"email\": \"test@example.com\", \"password\": \"password\"}}'\n```\n\nThe JWT token will be returned in the response headers.\n\n### Accessing a Protected API Endpoint\n\n#### Without token\n\n```sh\ncurl 'http://localhost:3000/secret'\n```\n\nResponse\n\n```json\n{\"error\":\"You need to sign in or sign up before continuing.\"}\n```\n\n#### With token\n\n```sh\ncurl 'http://localhost:3000/secret' -H 'Authorization: Bearer \u003ctoken\u003e'\n```\n\nResponse\n\n😉 Try and find out\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderhs%2Frails-api-only-devise-jwt-example-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderhs%2Frails-api-only-devise-jwt-example-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderhs%2Frails-api-only-devise-jwt-example-app/lists"}