{"id":18152414,"url":"https://github.com/chanioxaris/go-recaptcha","last_synced_at":"2025-04-30T08:57:41.521Z","repository":{"id":57556107,"uuid":"274239490","full_name":"chanioxaris/go-recaptcha","owner":"chanioxaris","description":"A package to handle verification for Google reCAPTCHA (v2 and v3)","archived":false,"fork":false,"pushed_at":"2020-09-28T18:09:15.000Z","size":23,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T00:05:06.609Z","etag":null,"topics":["golang","golang-library","golang-package","google-recaptcha","google-recaptcha-v2","google-recaptcha-v3","recaptcha","recaptcha-api","recaptcha-v2","recaptcha-v3","recaptcha-verification"],"latest_commit_sha":null,"homepage":"","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/chanioxaris.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":"CODEOWNERS","security":null,"support":null}},"created_at":"2020-06-22T20:50:45.000Z","updated_at":"2023-08-16T03:12:22.000Z","dependencies_parsed_at":"2022-09-02T12:51:14.645Z","dependency_job_id":null,"html_url":"https://github.com/chanioxaris/go-recaptcha","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fgo-recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fgo-recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fgo-recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chanioxaris%2Fgo-recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chanioxaris","download_url":"https://codeload.github.com/chanioxaris/go-recaptcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246332037,"owners_count":20760399,"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":["golang","golang-library","golang-package","google-recaptcha","google-recaptcha-v2","google-recaptcha-v3","recaptcha","recaptcha-api","recaptcha-v2","recaptcha-v3","recaptcha-verification"],"created_at":"2024-11-02T02:07:11.546Z","updated_at":"2025-03-31T14:30:32.673Z","avatar_url":"https://github.com/chanioxaris.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-recaptcha\n\n[Google reCAPTCHA](https://www.google.com/recaptcha/intro/v3.html) (v2 and v3) verification in Golang.\n\n## Install\n\nTo get the package:\n\n`go get github.com/chanioxaris/go-recaptcha`\n\n## Examples\n\nreCAPTCHA v2:\n\n- Simple usage with default values (httpClient: http.DefaultClient)\n\n        package main\n        \n        import (\n            \"fmt\"\n        \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func main() {\n            rec, err := recaptcha.New(\u003csecret\u003e, recaptcha.WithVersion(2))\n            if err != nil {\n                panic(err)\n            }\n        \n            if err = rec.Verify(\u003cresponse\u003e); err != nil {\n                panic(err)\n            }\n        \n            fmt.Println(\"Success\")\n        }\n        \n- Simple usage with custom http client\n\n        package main\n        \n        import (\n            \"fmt\"\n        \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func main() {\n            customClient := \u0026http.Client{Timeout: time.Second * 10}\n            \n            rec, err := recaptcha.New(\n                    \u003csecret\u003e, \n                    recaptcha.WithVersion(2), \n                    recaptcha.WithHTTPClient(customClient)\n                )\n            if err != nil {\n                panic(err)\n            }\n        \n            if err = rec.Verify(\u003cresponse\u003e); err != nil {\n                panic(err)\n            }\n        \n            fmt.Println(\"Success\")\n        }\n        \n- Get reCAPTCHA token from request body (`g-recaptcha-response` field)\n\n        import (\n        \t\"fmt\"\n        \t\"net/http\"\n        \n        \t\"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func Handler(w http.ResponseWriter, r *http.Request) {\n        \trec, err := recaptcha.New(\u003csecret\u003e, recaptcha.WithVersion(2))\n        \tif err != nil {\n        \t\tpanic(err)\n        \t}\n        \n        \tresponse, err := rec.GetRequestToken(r)\n        \tif err != nil {\n        \t\tpanic(err)\n        \t}\n        \n        \tif err = rec.Verify(response); err != nil {\n        \t\tpanic(err)\n        \t}\n        \n        \tfmt.Println(\"Success\")\n        }\n\nreCAPTCHA v3:\n\n- Simple usage with default values (version: 3, action: \"\", score: 0.5, httpClient: http.DefaultClient)\n\n        package main\n        \n        import (\n            \"fmt\"\n    \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n    \n        func main() {\n            rec, err := recaptcha.New(\u003csecret\u003e)\n            if err != nil {\n                panic(err)\n            }\n        \n            if err = rec.Verify(\u003cresponse\u003e); err != nil {\n                panic(err)\n            }\n        \n            fmt.Println(\"Success\")\n        }\n        \n- Simple usage with custom values\n\n        package main\n            \n        import (\n            \"fmt\"\n    \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func main() {\n             customClient := \u0026http.Client{Timeout: time.Second * 10}\n             customAction := \"custom-action\"\n             customScore := 0.7\n        \n            rec, err := recaptcha.New(\n                    \u003csecret\u003e, \n            \t\trecaptcha.WithHTTPClient(customClient), \n            \t\trecaptcha.WithAction(customAction), \n            \t\trecaptcha.WithScore(customScore),\n            \t)\n            if err != nil {\n                panic(err)\n            }\n        \n            if err = rec.Verify(\u003cresponse\u003e); err != nil {\n                panic(err)\n            }\n        \n            fmt.Println(\"Success\")\n        }\n\n- Get reCAPTCHA token from request body (`g-recaptcha-response` field)\n\n        package main\n                \n        import (\n            \"fmt\"\n            \"net/http\"\n        \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func Handler(w http.ResponseWriter, r *http.Request) {\n            rec, err := recaptcha.New(\u003csecret\u003e)\n            if err != nil {\n                panic(err)\n            }\n        \n            response, err := rec.GetRequestToken(r)\n            if err != nil {\n                panic(err)\n            }\n        \n            if err = rec.Verify(response); err != nil {\n                panic(err)\n            }\n        \n            fmt.Println(\"Success\")\n        }\n\nMiddleware:\n\n- Use middleware in REST API\n\n        package main\n    \n        import (\n            \"log\"\n            \"net/http\"\n        \n            \"github.com/gorilla/mux\"\n        \n            \"github.com/chanioxaris/go-recaptcha\"\n        )\n        \n        func main() {\n            // Create a new recaptcha instance.\n            rec, err := recaptcha.New(\u003csecret\u003e)\n            if err != nil {\n                panic(err)\n            }\n        \n            // Setup router.\n            router := mux.NewRouter().StrictSlash(true)\n            // Use the recaptcha middleware.\n            router.Use(recaptcha.Middleware(rec))\n        \n            // Setup endpoint handler.\n            router.HandleFunc(\"/\", func(w http.ResponseWriter, r *http.Request) {\n                w.Write([]byte(\"A Google reCAPTCHA protected endpoint\"))\n            })\n        \n            // Start server.\n            log.Fatal(http.ListenAndServe(\":8080\", router))\n        }\n\n## License\n\ngo-recaptcha is [MIT licensed](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanioxaris%2Fgo-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchanioxaris%2Fgo-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchanioxaris%2Fgo-recaptcha/lists"}