{"id":24201545,"url":"https://github.com/mstgnz/goauth","last_synced_at":"2026-06-09T05:32:33.332Z","repository":{"id":218194011,"uuid":"745848775","full_name":"mstgnz/goauth","owner":"mstgnz","description":"simple OAuth2 integration","archived":false,"fork":false,"pushed_at":"2026-04-21T20:17:40.000Z","size":121,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-21T22:26:06.098Z","etag":null,"topics":["go","oauth2"],"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/mstgnz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-01-20T10:30:38.000Z","updated_at":"2026-04-21T20:17:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"7615638e-cb36-47c0-a0a3-dd80c5179065","html_url":"https://github.com/mstgnz/goauth","commit_stats":null,"previous_names":["mstgnz/goauth"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mstgnz/goauth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstgnz%2Fgoauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstgnz%2Fgoauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstgnz%2Fgoauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstgnz%2Fgoauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mstgnz","download_url":"https://codeload.github.com/mstgnz/goauth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mstgnz%2Fgoauth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34093774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","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"],"created_at":"2025-01-13T21:16:19.764Z","updated_at":"2026-06-09T05:32:33.317Z","avatar_url":"https://github.com/mstgnz.png","language":"Go","funding_links":["https://docs.patreon.com/"],"categories":[],"sub_categories":[],"readme":"# goauth\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/mstgnz/goauth.svg)](https://pkg.go.dev/github.com/mstgnz/goauth)\n[![Go Report Card](https://goreportcard.com/badge/github.com/mstgnz/goauth)](https://goreportcard.com/report/github.com/mstgnz/goauth)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA comprehensive Go package that provides a unified interface for OAuth2 authentication across multiple providers. This package simplifies the integration of OAuth2 authentication in your Go applications by offering a consistent API for various OAuth2 providers.\n\n## Features\n\n- Unified interface for all OAuth2 providers\n- Easy-to-use API\n- Type-safe implementation\n- Extensive provider support\n- Built-in token management\n- Standardized user information\n- Customizable scopes\n- Error handling\n- Token refresh support\n\n## Installation\n\n```bash\ngo get -u github.com/mstgnz/goauth\n```\n\n## Quick Start\n\nHere's a simple example using GitHub OAuth2:\n\n```go\npackage main\n\nimport (\n    \"log\"\n    \"net/http\"\n    \"github.com/mstgnz/goauth/initialize\"\n    \"golang.org/x/oauth2\"\n)\n\nfunc main() {\n    // Initialize the provider\n    provider, err := initialize.NewProviderByName(\"github\")\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Configure the provider\n    provider.SetClientId(\"your-client-id\")\n    provider.SetClientSecret(\"your-client-secret\")\n    provider.SetRedirectUrl(\"http://localhost:8080/callback\")\n    provider.SetScopes([]string{\"read:user\", \"user:email\"})\n\n    // Setup login handler\n    http.HandleFunc(\"/login\", func(w http.ResponseWriter, r *http.Request) {\n        url := provider.BuildAuthUrl(\"state\", oauth2.AccessTypeOffline)\n        http.Redirect(w, r, url, http.StatusTemporaryRedirect)\n    })\n\n    // Setup callback handler\n    http.HandleFunc(\"/callback\", func(w http.ResponseWriter, r *http.Request) {\n        // Exchange code for token\n        token, err := provider.FetchToken(r.URL.Query().Get(\"code\"))\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusInternalServerError)\n            return\n        }\n\n        // Get user information\n        user, err := provider.FetchUser(token)\n        if err != nil {\n            http.Error(w, err.Error(), http.StatusInternalServerError)\n            return\n        }\n\n        log.Printf(\"Logged in user: %+v\", user)\n    })\n\n    log.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n## Supported Providers\n\nThe package currently supports the following OAuth2 providers:\n\n| Provider | Documentation |\n|----------|--------------|\n| Apple | [Apple Developer](https://developer.apple.com/) |\n| Discord | [Discord Developer](https://discord.com/developers/docs) |\n| Facebook | [Facebook for Developers](https://developers.facebook.com/) |\n| Gitea | [Gitea Developer](https://gitea.io/en-us/docs/) |\n| Gitee | [Gitee Developer](https://gitee.com/help) |\n| GitHub | [GitHub Developer](https://developer.github.com/) |\n| GitLab | [GitLab Developer](https://docs.gitlab.com/ee/api/) |\n| Google | [Google Identity Platform](https://developers.google.com/identity) |\n| Instagram | [Instagram Graph API](https://developers.facebook.com/docs/instagram-api) |\n| Kakao | [Kakao Developers](https://developers.kakao.com/) |\n| LiveChat | [LiveChat API](https://developers.livechat.com/docs/rest-api/) |\n| Mailcow | [Mailcow API](https://mailcow.github.io/mailcow-dockerized-docs/) |\n| Microsoft | [Microsoft Identity Platform](https://docs.microsoft.com/en-us/azure/active-directory/develop/) |\n| OIDC | [OpenID Connect](https://openid.net/connect/) |\n| Patreon | [Patreon API](https://docs.patreon.com/#introduction) |\n| Spotify | [Spotify for Developers](https://developer.spotify.com/documentation/general/) |\n| Strava | [Strava API](https://developers.strava.com/) |\n| Twitch | [Twitch Developers](https://dev.twitch.tv/docs) |\n| X (Twitter) | [X Developer](https://developer.x.com/) |\n| VK | [VK API](https://vk.com/dev) |\n| Yandex | [Yandex Passport API](https://yandex.com/dev/passport/) |\n\n## Advanced Usage\n\n### Custom Scopes\n\n```go\nprovider.SetScopes([]string{\n    \"read:user\",\n    \"user:email\",\n    \"custom:scope\",\n})\n```\n\n### Token Refresh\n\n```go\nnewToken, err := provider.RefreshToken(oldToken)\nif err != nil {\n    log.Fatal(err)\n}\n```\n\n### Custom HTTP Client\n\n```go\nclient := provider.Client(token)\nresp, err := client.Get(\"https://api.provider.com/endpoint\")\n```\n\n## Best Practices\n\n1. **Environment Variables**: Store sensitive credentials in environment variables\n   ```go\n   provider.SetClientId(os.Getenv(\"OAUTH_CLIENT_ID\"))\n   provider.SetClientSecret(os.Getenv(\"OAUTH_CLIENT_SECRET\"))\n   ```\n\n2. **State Parameter**: Always validate the state parameter\n   ```go\n   if r.URL.Query().Get(\"state\") != expectedState {\n       http.Error(w, \"Invalid state parameter\", http.StatusBadRequest)\n       return\n   }\n   ```\n\n3. **Error Handling**: Implement proper error handling\n   ```go\n   if err := provider.ValidateConfig(); err != nil {\n       log.Fatal(\"Configuration error:\", err)\n   }\n   ```\n\n## Security Considerations\n\n- Always use HTTPS in production\n- Implement CSRF protection using the state parameter\n- Store tokens securely\n- Use environment variables for credentials\n- Implement PKCE when available\n- Keep scopes to minimum required\n- Properly handle token expiration and refresh\n\n## Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\nIf you encounter any issues or have questions, please file an issue on the [GitHub repository](https://github.com/mstgnz/goauth/issues).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstgnz%2Fgoauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmstgnz%2Fgoauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmstgnz%2Fgoauth/lists"}