{"id":30773366,"url":"https://github.com/syniol/golang-oauth2","last_synced_at":"2025-12-30T21:30:19.182Z","repository":{"id":163226083,"uuid":"618631272","full_name":"syniol/golang-oauth2","owner":"syniol","description":"OAuth 2.1 Password Grant Type implementation in Go","archived":false,"fork":false,"pushed_at":"2025-08-06T22:26:25.000Z","size":75,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-06T23:22:01.173Z","etag":null,"topics":["authentication","docker","docker-compose","go","golang","oauth2","password-grant","postgres","postgresql","redis","redis-cache"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syniol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-03-24T22:47:29.000Z","updated_at":"2025-08-06T22:26:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"89115b7a-654d-4bd5-acaa-5191105c8c64","html_url":"https://github.com/syniol/golang-oauth2","commit_stats":null,"previous_names":["syniol/golang-oauth2","syniol/golang-oauth-password-grant"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/syniol/golang-oauth2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syniol%2Fgolang-oauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syniol%2Fgolang-oauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syniol%2Fgolang-oauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syniol%2Fgolang-oauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syniol","download_url":"https://codeload.github.com/syniol/golang-oauth2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syniol%2Fgolang-oauth2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273699716,"owners_count":25152285,"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-09-04T02:00:08.968Z","response_time":61,"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":["authentication","docker","docker-compose","go","golang","oauth2","password-grant","postgres","postgresql","redis","redis-cache"],"created_at":"2025-09-05T01:50:42.803Z","updated_at":"2025-12-30T21:30:19.176Z","avatar_url":"https://github.com/syniol.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OAuth 2.1 Password Grant Type in Golang\n![workflow](https://github.com/syniol/golang-oauth2/actions/workflows/makefile.yml/badge.svg)\n\nImplementation of standard OAuth 2.1 for Password Grant type in Golang and its native HTTP server.\n\n\n## Healthcheck API\n```text\nGET  oauth2/healthz HTTP/1.1\nHost: 127.0.0.1\nContent-Type: text/plain\n```\n\n__Request:__\n```bash\ncurl -k --location --request GET 'https://127.0.0.1/healthz'\n```\n\n__Response:__\nStatus code `200` (OK) and a simple body response `ok` indicates API is working and operational.\n```text\nok\n```\n\n\n## Clients API\nClients endpoint is responsible for creating a new client/user to be inserted in database.\n\n```text\nPOST  oauth2/clients HTTP/1.1\nHost: 127.0.0.1\nContent-Type: application/json\n```\n\n__Request:__\n```bash\ncurl -k --location --request POST 'https://127.0.0.1/oauth2/clients' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{\n    \"username\": \"johndoe\",\n    \"password\": \"johnspassword1\"\n}'\n```\n\n__Response:__\n```json\n{\n  \"client_id\": \"a9a6b145-fafe-415c-a92e-c79cbd57567d\"\n}\n```\n\n\n## Token API\nAfter client registration you can create a token sending a `POST` request to this endpoint.\n\n```text\nPOST  oauth2/token HTTP/1.1\nHost: 127.0.0.1\nContent-Type: application/x-www-form-urlencoded\n```\n\n__Request:__\n```bash\ncurl -k --location --request POST 'https://127.0.0.1/oauth2/token' \\\n--header 'Content-Type: application/x-www-form-urlencoded' \\\n--data-urlencode 'grant_type=password' \\\n--data-urlencode 'username=johndoe' \\\n--data-urlencode 'password=johnspassword1'\n```\n\n__Response:__\n```json\n{\n  \"access_token\": \"MmVjZGFiNmY4Y2E2OTQ1ZWNmMGYz...FkMDM=\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 3600\n}\n```\n\n\n## Up \u0026 Running\nThere are a few commands available, you could explore the available options by running `make`. This \nshould give you a glossary of available methods. For example to deploy the service, you can run:\n\n```bash\n  make deploy\n```\n\n\n### Debug\nIn order to run debugger you could create a config on your IDE and enable `DEBUG` env variable in your \nlocal environment. You will need database \u0026 cache storage from docker; you could enable them with:\n\n```bash\n  make debug\n```\n\n![img](https://github.com/syniol/golang-oauth-password-grant/assets/68777073/5c24392a-29df-41c2-8f11-fd32a1053222)\n\n\n### Todos\n * [ ] Add more documents about this repository and RFC Standard for OAuth 2.1 especially for `password_grant`\n * [ ] Convert Http Error response to JSON response `errors: []`\n * [ ] Investigate possibility of volume share for Redis \u0026 Go (app) to share TLS certs\n * [ ] Separate the Docker network for proxy and app to exclude Database (Postgres) \u0026 Cache (Redis)\n * [ ] Increase code coverage\n\n\n#### Credits\nAuthor: [Hadi Tajallaei](mailto:hadi@syniol.com)\n\nCopyright \u0026copy; 2023-2025 Syniol Limited. All rights reserved.\n\n_Please see a [LICENSE file](https://github.com/syniol/golang-oauth-password-grant/blob/main/LICENSE)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyniol%2Fgolang-oauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyniol%2Fgolang-oauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyniol%2Fgolang-oauth2/lists"}