{"id":18298318,"url":"https://github.com/fusionauth/go-client","last_synced_at":"2025-04-07T05:10:58.874Z","repository":{"id":41141664,"uuid":"175434517","full_name":"FusionAuth/go-client","owner":"FusionAuth","description":"FusionAuth Go Client Library!","archived":false,"fork":false,"pushed_at":"2025-03-31T22:28:08.000Z","size":1080,"stargazers_count":30,"open_issues_count":27,"forks_count":31,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-04-01T16:56:44.860Z","etag":null,"topics":["fusionauth","fusionauth-client","go-client","golang","golang-client"],"latest_commit_sha":null,"homepage":"https://fusionauth.io/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FusionAuth.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-13T14:13:59.000Z","updated_at":"2025-03-31T19:14:36.000Z","dependencies_parsed_at":"2023-10-11T03:18:56.079Z","dependency_job_id":"a5f4a1d7-08f7-4ef2-bbff-32b3a6433669","html_url":"https://github.com/FusionAuth/go-client","commit_stats":{"total_commits":437,"total_committers":23,"mean_commits":19.0,"dds":0.2723112128146453,"last_synced_commit":"3c38fd514d84c7294152d9e9fb24e9752830e72c"},"previous_names":["fusionauth/fusionauth-go-client"],"tags_count":141,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Fgo-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Fgo-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Fgo-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Fgo-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FusionAuth","download_url":"https://codeload.github.com/FusionAuth/go-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"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":["fusionauth","fusionauth-client","go-client","golang","golang-client"],"created_at":"2024-11-05T15:05:46.894Z","updated_at":"2025-04-07T05:10:58.849Z","avatar_url":"https://github.com/FusionAuth.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## FusionAuth Go Client ![semver 2.0.0 compliant](http://img.shields.io/badge/semver-2.0.0-brightgreen.svg?style=flat-square) [![Documentation](https://godoc.org/github.com/FusionAuth/go-client?status.svg)](http://godoc.org/github.com/FusionAuth/go-client/pkg/fusionauth)\n\n\nUse this client to access the FusionAuth APIs in your Go application. For additional information and documentation on FusionAuth refer to [https://fusionauth.io](https://fusionauth.io).\n\n## Credits\n- [@medhir](https://github.com/medhir) Thank you for the initial commit and initial implementation of the Go client!\n- [@markschmid](https://github.com/markschmid) Thank you for your PRs, feedback and suggestions! \n- [@MCBrandenburg](https://github.com/MCBrandenburg) Thank you for the feedback and PRs!\n- [@matthewhartstonge](https://github.com/matthewhartstonge) Thank you for the PR!\n- The FusionAuth team - couldn't have done it without you!\n\n## Installation\n\n```\ngo get github.com/FusionAuth/go-client/pkg/fusionauth\n```\n\n## Example Usage\n\nThe following example uses the FusionAuth Go client to create a request handling function that logs in a user: \n```go\npackage example\n\nimport (\n    \"encoding/json\"\n    \"net/http\"\n    \"net/url\"\n    \"time\"\n    \n    \"github.com/FusionAuth/go-client/pkg/fusionauth\"\n)\n\nconst host = \"http://localhost:9011\"\n\nvar apiKey = \"YOUR_FUSIONAUTH_API_KEY\"\nvar httpClient = \u0026http.Client{\n\tTimeout: time.Second * 10,\n}\n\nvar baseURL, _ = url.Parse(host)\n\n// Construct a new FusionAuth Client\nvar auth = fusionauth.NewClient(httpClient, baseURL, apiKey)\n\n// Login logs in the user using the FusionAuth Go client library\nfunc Login() http.HandlerFunc {\n    return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        // Read response body\n        var credentials fusionauth.LoginRequest\n        defer r.Body.Close()\n        json.NewDecoder(r.Body).Decode(\u0026credentials)\n        // Use FusionAuth Go client to log in the user\n        authResponse, errors, err := auth.Login(credentials)\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusBadRequest)\n            return\n        }\n        // Write the response from the FusionAuth client as JSON\n        var responseJSON []byte\n        if errors != nil {\n            responseJSON, err = json.Marshal(errors)\n        } else {\n            responseJSON, err = json.Marshal(authResponse)\n        }\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusInternalServerError)\n            return\n        }\n        w.Header().Set(\"Content-Type\", \"application/json\")\n        w.WriteHeader(http.StatusOK)\n        w.Write(responseJSON)\n    })\n}\n```\n\nYou can also call the API directly without logging a user in. This code uses an API key to determine the number of tenants in a FusionAuth installation.\n\n```\npackage main\n\nimport (\n    \"net/http\"\n    \"net/url\"\n    \"time\"\n    \"fmt\"\n    \n    \"github.com/FusionAuth/go-client/pkg/fusionauth\"\n)\n\nconst host = \"http://localhost:9011\"\n\nvar apiKey = \"API KEY\"\nvar httpClient = \u0026http.Client{\n    Timeout: time.Second * 10,\n}\n\nfunc main() {\n    var baseURL, _ = url.Parse(host)\n\n    // Construct a new FusionAuth Client\n    var client = fusionauth.NewClient(httpClient, baseURL, apiKey)\n    \n    // for production code, don't ignore the error!\n    tenantResponse, _ := client.RetrieveTenants()\n    \n    fmt.Print(len(tenantResponse.Tenants))\n}\n```\n\n## Testing source builds\n\nIf you are modifying the go client and want to test it locally, follow these steps:\n\ngo to directory where you have go code checked out.\n\n```\nmkdir test2\ncd test2\ngo mod init example.com/test/fusionauth\ngo mod tidy\nvi test.go # put in your test code, in the main package\n```\n\nThen edit `go.mod` and add these lines at the bottom:\n\n```\nrequire (\n        github.com/FusionAuth/go-client v1.0.0\n)\n\nreplace (\n        github.com/FusionAuth/go-client v1.0.0 =\u003e ../go-client\n)\n```\n\nThen you can run it: `go run test.go # or go build`\n\nHT https://levelup.gitconnected.com/import-and-use-local-packages-in-your-go-application-885c35e5624 for these.\n\n## Questions and support\n\nIf you have a question or support issue regarding this client library, we'd love to hear from you.\n\nIf you have a paid edition with support included, please [open a ticket in your account portal](https://account.fusionauth.io/account/support/). Learn more about [paid editions here](https://fusionauth.io/pricing).\n\nOtherwise, please [post your question in the community forum](https://fusionauth.io/community/forum/).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/go-client.\n\nIf you find an issue with syntax, etc - this is likely a bug in the template. Feel free to submit a PR against the Client Builder project.\n- [Client Builder](https://github.com/FusionAuth/fusionauth-client-builder)\n- [go.client.ftl](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/go.client.ftl)\n- [go.domain.ftl](https://github.com/FusionAuth/fusionauth-client-builder/blob/master/src/main/client/go.domain.ftl)\n\n## License\n\nThe code is available as open source under the terms of the [Apache v2.0 License](https://opensource.org/licenses/Apache-2.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusionauth%2Fgo-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusionauth%2Fgo-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusionauth%2Fgo-client/lists"}