{"id":13563219,"url":"https://github.com/ezzarghili/recaptcha-go","last_synced_at":"2025-08-12T15:32:08.482Z","repository":{"id":54510316,"uuid":"115212023","full_name":"ezzarghili/recaptcha-go","owner":"ezzarghili","description":"Validate Google reCAPTCHA v2 \u0026 v3 form submission package in golang","archived":false,"fork":false,"pushed_at":"2021-02-14T16:35:43.000Z","size":45,"stargazers_count":66,"open_issues_count":3,"forks_count":14,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-01T07:38:24.292Z","etag":null,"topics":["golang","google-recaptcha","recaptcha","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/ezzarghili.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}},"created_at":"2017-12-23T17:45:52.000Z","updated_at":"2025-02-19T14:11:13.000Z","dependencies_parsed_at":"2022-08-13T18:10:46.637Z","dependency_job_id":null,"html_url":"https://github.com/ezzarghili/recaptcha-go","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/ezzarghili/recaptcha-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzarghili%2Frecaptcha-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzarghili%2Frecaptcha-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzarghili%2Frecaptcha-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzarghili%2Frecaptcha-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ezzarghili","download_url":"https://codeload.github.com/ezzarghili/recaptcha-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ezzarghili%2Frecaptcha-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270086845,"owners_count":24524658,"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-08-12T02:00:09.011Z","response_time":80,"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":["golang","google-recaptcha","recaptcha","recaptcha-verification"],"created_at":"2024-08-01T13:01:16.550Z","updated_at":"2025-08-12T15:32:08.173Z","avatar_url":"https://github.com/ezzarghili.png","language":"Go","funding_links":[],"categories":["Go","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# recaptcha-go\n\n[![Build Status](https://travis-ci.org/ezzarghili/recaptcha-go.svg?branch=master)](https://travis-ci.org/ezzarghili/recaptcha-go)\n\nGoogle reCAPTCHA v2 \u0026 v3 form submission verification in golang.\n\n## Usage\n\nThe API has changed form last version hence the new major version change.  \nOld API is still available using the package `gopkg.in/ezzarghili/recaptcha-go.v2` although it does not provide all options available in this version.  \nAs always install the package in your environment by using a stable API version, see latest version in [releases page](https://github.com/ezzarghili/recaptcha-go/releases).\n\n```bash\ngo get -u gopkg.in/ezzarghili/recaptcha-go.v4 \n```\n\n### recaptcha v2 API\n\n```go\nimport \"gopkg.in/ezzarghili/recaptcha-go.v4\"\nfunc main(){\n    captcha, _ := recaptcha.NewReCAPTCHA(recaptchaSecret, recaptcha.V2, 10 * time.Second) // for v2 API get your secret from https://www.google.com/recaptcha/admin\n}\n```\n\nNow everytime you need to verify a V2 API client with no special options request use.\n\n```go\nerr := captcha.Verify(recaptchaResponse)\nif err != nil {\n    // do something with err (log?)\n    // Example check error codes array if they exist: (err.(*recaptcha.Error)).ErrorCodes\n}\n// proceed\n```\n\nFor specific options use the `VerifyWithOptions` method  \nAvailable options for the v2 api are:\n\n```go\n  Hostname       string\n  ApkPackageName string\n  ResponseTime   time.Duration\n  RemoteIP       string\n```\n\nOther v3 options are ignored and method will return `nil` when succeeded.\n\n```go\nerr := captcha.VerifyWithOptions(recaptchaResponse, VerifyOption{RemoteIP: \"123.123.123.123\"})\nif err != nil {\n    // do something with err (log?)\n    // Example check error codes array if they exist: (err.(*recaptcha.Error)).ErrorCodes\n}\n// proceed\n```\n\n### recaptcha v3 API\n\n```go\nimport \"gopkg.in/ezzarghili/recaptcha-go.v4\"\nfunc main(){\n    captcha, _ := recaptcha.NewReCAPTCHA(recaptchaSecret, recaptcha.V3, 10 * time.Second) // for v3 API use https://g.co/recaptcha/v3 (apperently the same admin UI at the time of writing)\n}\n```\n\nNow everytime you need to verify a V3 API client with no special options request use.\n\n```go\nerr := captcha.Verify(recaptchaResponse)\nif err != nil {\n    // do something with err (log?)\n}\n// proceed\n```\nNote that as recaptcha v3 use score for challenge validation, if no threshold option is set the **default** value is `0.5`\n\nFor specific options use the `VerifyWithOptions` method.  \nAvailable options for the v3 api are:\n\n```go\n   Threshold      float32\n   Action         string\n   Hostname       string\n   ApkPackageName string\n   ResponseTime   time.Duration\n   RemoteIP       string\n```\n\n```go\nerr := captcha.VerifyWithOptions(recaptchaResponse, VerifyOption{Action: \"hompage\", Threshold: 0.8})\nif err != nil {\n    // do something with err (log?)\n}\n// proceed\n```\n\nWhile `recaptchaResponse` is the form value with name `g-recaptcha-response` sent back by recaptcha server and set for you in the form when a user answers the challenge.\n\nBoth `recaptcha.Verify` and `recaptcha.VerifyWithOptions` return a `error` or `nil` if successful.\n\nUse the `error` to check for issues with the secret, connection with the server, options mismatches and incorrect solution.\n\nThis version made timeout explcit to make sure users have the possiblity to set the underling http client timeout suitable for their implemetation.\n\n### Run Tests\n\nUse the standard go means of running test.\nYou can also check examples of usage in the tests.\n\n```bash\ngo test\n```\n\n### Issues with this library\n\nIf you have some problems with using this library, bug reports or enhancement please open an issue in the issues tracker.\n\n### License\n\nLet's go with something permitive should we?\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezzarghili%2Frecaptcha-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fezzarghili%2Frecaptcha-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fezzarghili%2Frecaptcha-go/lists"}