{"id":13493301,"url":"https://github.com/go-oauth2/oauth2","last_synced_at":"2026-10-19T00:50:15.051Z","repository":{"id":37756278,"uuid":"59758059","full_name":"go-oauth2/oauth2","owner":"go-oauth2","description":"OAuth 2.0 server library for the Go programming language.","archived":false,"fork":false,"pushed_at":"2026-09-01T12:19:48.000Z","size":1067,"stargazers_count":3623,"open_issues_count":115,"forks_count":592,"subscribers_count":62,"default_branch":"master","last_synced_at":"2026-10-05T14:22:10.567Z","etag":null,"topics":["go-oauth2","go-oauth2-server","oauth2","oauth2-authentication","oauth2-provider","oauth2-server"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/go-oauth2/oauth2/v4","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/go-oauth2.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}},"created_at":"2016-05-26T14:42:51.000Z","updated_at":"2026-10-02T15:14:23.000Z","dependencies_parsed_at":"2024-05-06T02:29:58.428Z","dependency_job_id":"b9ae4ca2-f26b-4460-a346-de6dbdb1c6b4","html_url":"https://github.com/go-oauth2/oauth2","commit_stats":{"total_commits":182,"total_committers":50,"mean_commits":3.64,"dds":"0.44505494505494503","last_synced_commit":"d1b58c7e627024ddaab9cd4a8a5e4676f623bf28"},"previous_names":[],"tags_count":67,"template":false,"template_full_name":null,"purl":"pkg:github/go-oauth2/oauth2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-oauth2%2Foauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-oauth2%2Foauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-oauth2%2Foauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-oauth2%2Foauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-oauth2","download_url":"https://codeload.github.com/go-oauth2/oauth2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-oauth2%2Foauth2/sbom","scorecard":{"id":432251,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-oauth2/oauth2","commit":"bb6e415e9b625f5109f64f9bad0897141cc2f8dd"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Code-Review","score":9,"reason":"Found 10/11 approved changesets -- score normalized to 9","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3553 / GHSA-mh63-6h87-95cp","Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9","Warn: Project is vulnerable to: GO-2022-0603 / GHSA-hp87-p4gw-j4gq"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T03:38:47.902Z","repository_id":37756278,"created_at":"2025-08-19T03:38:47.902Z","updated_at":"2025-08-19T03:38:47.902Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":344872684,"owners_count":38344159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-10-03T21:59:58.778Z","status":"online","status_checked_at":"2026-10-18T02:00:06.448Z","response_time":63,"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":["go-oauth2","go-oauth2-server","oauth2","oauth2-authentication","oauth2-provider","oauth2-server"],"created_at":"2024-07-31T19:01:14.012Z","updated_at":"2026-10-19T00:50:14.724Z","avatar_url":"https://github.com/go-oauth2.png","language":"Go","funding_links":[],"categories":["Go","Authentication \u0026 OAuth","Security"],"sub_categories":["Authentication and Authorization"],"readme":"# Golang OAuth 2.0 Server\n\n\u003e An open protocol to allow secure authorization in a simple and standard method from web, mobile and desktop applications.\n\n[![Build][build-status-image]][build-status-url] [![Codecov][codecov-image]][codecov-url] [![ReportCard][reportcard-image]][reportcard-url] [![GoDoc][godoc-image]][godoc-url] [![License][license-image]][license-url]\n\n## Protocol Flow\n\n```text\n     +--------+                               +---------------+\n     |        |--(A)- Authorization Request -\u003e|   Resource    |\n     |        |                               |     Owner     |\n     |        |\u003c-(B)-- Authorization Grant ---|               |\n     |        |                               +---------------+\n     |        |\n     |        |                               +---------------+\n     |        |--(C)-- Authorization Grant --\u003e| Authorization |\n     | Client |                               |     Server    |\n     |        |\u003c-(D)----- Access Token -------|               |\n     |        |                               +---------------+\n     |        |\n     |        |                               +---------------+\n     |        |--(E)----- Access Token ------\u003e|    Resource   |\n     |        |                               |     Server    |\n     |        |\u003c-(F)--- Protected Resource ---|               |\n     +--------+                               +---------------+\n```\n\n## Quick Start\n\n### Download and install\n\n```bash\ngo get -u -v github.com/go-oauth2/oauth2/v4/...\n```\n\n### Create file `server.go`\n\n```go\npackage main\n\nimport (\n\t\"log\"\n\t\"net/http\"\n\n\t\"github.com/go-oauth2/oauth2/v4/errors\"\n\t\"github.com/go-oauth2/oauth2/v4/manage\"\n\t\"github.com/go-oauth2/oauth2/v4/models\"\n\t\"github.com/go-oauth2/oauth2/v4/server\"\n\t\"github.com/go-oauth2/oauth2/v4/store\"\n)\n\nfunc main() {\n\tmanager := manage.NewDefaultManager()\n\t// token memory store\n\tmanager.MustTokenStorage(store.NewMemoryTokenStore())\n\n\t// client memory store\n\tclientStore := store.NewClientStore()\n\tclientStore.Set(\"000000\", \u0026models.Client{\n\t\tID:     \"000000\",\n\t\tSecret: \"999999\",\n\t\tDomain: \"http://localhost\",\n\t})\n\tmanager.MapClientStorage(clientStore)\n\n\tsrv := server.NewDefaultServer(manager)\n\tsrv.SetAllowGetAccessRequest(true)\n\tsrv.SetClientInfoHandler(server.ClientFormHandler)\n\n\tsrv.UserAuthorizationHandler = func(w http.ResponseWriter, r *http.Request) (userID string, err error) {\n\t\treturn \"000000\", nil\n\t}\n\n\tsrv.SetInternalErrorHandler(func(err error) (re *errors.Response) {\n\t\tlog.Println(\"Internal Error:\", err.Error())\n\t\treturn\n\t})\n\n\tsrv.SetResponseErrorHandler(func(re *errors.Response) {\n\t\tlog.Println(\"Response Error:\", re.Error.Error())\n\t})\n\n\thttp.HandleFunc(\"/authorize\", func(w http.ResponseWriter, r *http.Request) {\n\t\terr := srv.HandleAuthorizeRequest(w, r)\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t}\n\t})\n\n\thttp.HandleFunc(\"/token\", func(w http.ResponseWriter, r *http.Request) {\n\t\tsrv.HandleTokenRequest(w, r)\n\t})\n\n\tlog.Fatal(http.ListenAndServe(\":9096\", nil))\n}\n\n```\n\n### Build and run\n\n```bash\ngo build server.go\n\n./server\n```\n\n### Open in your web browser\n**Authorization Request**:\n[http://localhost:9096/authorize?client_id=000000\u0026response_type=code](http://localhost:9096/authorize?client_id=000000\u0026response_type=code)\n\n**Grant Token Request**:\n[http://localhost:9096/token?grant_type=client_credentials\u0026client_id=000000\u0026client_secret=999999\u0026scope=read](http://localhost:9096/token?grant_type=client_credentials\u0026client_id=000000\u0026client_secret=999999\u0026scope=read)\n\n```json\n{\n  \"access_token\": \"J86XVRYSNFCFI233KXDL0Q\",\n  \"expires_in\": 7200,\n  \"scope\": \"read\",\n  \"token_type\": \"Bearer\"\n}\n```\n\n## Features\n\n- Easy to use\n- Based on the [RFC 6749](https://tools.ietf.org/html/rfc6749) implementation\n- Token storage support TTL\n- Support custom expiration time of the access token\n- Support custom extension field\n- Support custom scope\n- Support jwt to generate access tokens\n\n## Example\n\n\u003e A complete example of simulation authorization code model\n\nSimulation examples of authorization code model, please check [example](/example)\n\n### Use jwt to generate access tokens\n\n```go\n\nimport (\n\t\"github.com/go-oauth2/oauth2/v4/generates\"\n\t\"github.com/dgrijalva/jwt-go\"\n)\n\n// ...\nmanager.MapAccessGenerate(generates.NewJWTAccessGenerate(\"\", []byte(\"00000000\"), jwt.SigningMethodHS512))\n\n// Parse and verify jwt access token\ntoken, err := jwt.ParseWithClaims(access, \u0026generates.JWTAccessClaims{}, func(t *jwt.Token) (interface{}, error) {\n\tif _, ok := t.Method.(*jwt.SigningMethodHMAC); !ok {\n\t\treturn nil, fmt.Errorf(\"parse error\")\n\t}\n\treturn []byte(\"00000000\"), nil\n})\nif err != nil {\n\t// panic(err)\n}\n\nclaims, ok := token.Claims.(*generates.JWTAccessClaims)\nif !ok || !token.Valid {\n\t// panic(\"invalid token\")\n}\n```\n\n## Store Implements\n\n- [BuntDB](https://github.com/tidwall/buntdb)(default store)\n- [Redis](https://github.com/go-oauth2/redis)\n- [MongoDB](https://github.com/go-oauth2/mongo)\n- [MySQL](https://github.com/go-oauth2/mysql)\n- [MySQL (Provides both client and token store)](https://github.com/imrenagi/go-oauth2-mysql)\n- [PostgreSQL](https://github.com/vgarvardt/go-oauth2-pg)\n- [DynamoDB](https://github.com/contamobi/go-oauth2-dynamodb)\n- [XORM](https://github.com/techknowlogick/go-oauth2-xorm)\n- [XORM (MySQL, client and token store)](https://github.com/rainlay/go-oauth2-xorm)\n- [GORM](https://github.com/techknowlogick/go-oauth2-gorm)\n- [Firestore](https://github.com/tslamic/go-oauth2-firestore)\n- [Hazelcast](https://github.com/clowre/go-oauth2-hazelcast) (token only)\n\n## Handy Utilities\n\n- [OAuth2 Proxy Logger (Debug utility that proxies interfaces and logs)](https://github.com/aubelsb2/oauth2-logger-proxy)\n\n## MIT License\n\nCopyright (c) 2016 Lyric\n\n[build-status-url]: https://travis-ci.org/go-oauth2/oauth2\n[build-status-image]: https://travis-ci.org/go-oauth2/oauth2.svg?branch=master\n[codecov-url]: https://codecov.io/gh/go-oauth2/oauth2\n[codecov-image]: https://codecov.io/gh/go-oauth2/oauth2/branch/master/graph/badge.svg\n[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/oauth2/v4\n[reportcard-image]: https://goreportcard.com/badge/github.com/go-oauth2/oauth2/v4\n[godoc-url]: https://godoc.org/github.com/go-oauth2/oauth2/v4\n[godoc-image]: https://godoc.org/github.com/go-oauth2/oauth2/v4?status.svg\n[license-url]: http://opensource.org/licenses/MIT\n[license-image]: https://img.shields.io/npm/l/express.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-oauth2%2Foauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-oauth2%2Foauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-oauth2%2Foauth2/lists"}