{"id":17138385,"url":"https://github.com/kevinburke/google-oauth-handler","last_synced_at":"2025-04-13T09:53:08.788Z","repository":{"id":57488571,"uuid":"87583335","full_name":"kevinburke/google-oauth-handler","owner":"kevinburke","description":"HTTP middleware for handling Google authentication","archived":false,"fork":false,"pushed_at":"2019-08-27T06:14:38.000Z","size":24,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T01:22:13.554Z","etag":null,"topics":["golang","google","google-oauth-handler","middleware","oauth2"],"latest_commit_sha":null,"homepage":null,"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/kevinburke.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-04-07T20:13:14.000Z","updated_at":"2019-08-27T18:51:05.000Z","dependencies_parsed_at":"2022-08-29T15:01:44.634Z","dependency_job_id":null,"html_url":"https://github.com/kevinburke/google-oauth-handler","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinburke%2Fgoogle-oauth-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinburke%2Fgoogle-oauth-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinburke%2Fgoogle-oauth-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinburke%2Fgoogle-oauth-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinburke","download_url":"https://codeload.github.com/kevinburke/google-oauth-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695304,"owners_count":21146952,"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","google","google-oauth-handler","middleware","oauth2"],"created_at":"2024-10-14T20:09:28.690Z","updated_at":"2025-04-13T09:53:08.765Z","avatar_url":"https://github.com/kevinburke.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# google-oauth-handler\n\nPackage `google_oauth_handler` transparently handles OAuth authentication with\nGoogle.\n\nCreate an Authenticator and then insert it as middleware in front of any\nresources you want to protect behind Google login, via authenticator.Handle.\nHandle will call the next middleware with (w, r, *Auth), which you can use\nto make requests to the Google API.\n\nThe Authenticator handles the OAuth workflow for you, redirecting users to\nGoogle, handling the callback and setting an encrypted cookie in the user's\nbrowser.\n\nFor more information, see the [godoc documentation][godoc].\n\n[godoc]: https://godoc.org/github.com/kevinburke/google-oauth-handler\n\n### Example\n\n```go\npackage google_oauth_handler_test\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"net/http\"\n\n\tgoogle \"github.com/kevinburke/google-oauth-handler\"\n\t\"golang.org/x/oauth2\"\n)\n\nvar key *[32]byte\n\nfunc init() {\n\tsecretKeyBytes, _ := hex.DecodeString(\"982a732cc3d72d13678dee2609cf55d736711ff1f293f95cab41bd45e5d77870\")\n\tkey = new([32]byte)\n\tcopy(key[:], secretKeyBytes)\n}\n\nfunc Example() {\n\tcfg := google.Config{\n\t\tSecretKey: key,\n\t\tBaseURL:   \"https://example.com\",\n\t\tClientID:  \"customdomain.apps.googleusercontent.com\",\n\t\tSecret:    \"W-secretkey\",\n\t\tScopes: []string{\n\t\t\t\"email\",\n\t\t\t\"https://www.googleapis.com/auth/gmail.send\",\n\t\t},\n\t}\n\tauth := google.NewAuthenticator(cfg)\n\thttp.Handle(\"/\", auth.Handle(func(w http.ResponseWriter, r *http.Request, auth *google.Auth) {\n\t\tfmt.Fprintf(w, \"\u003chtml\u003e\u003cbody\u003e\u003ch1\u003eHello World\u003c/h1\u003e\u003cp\u003eToken: %s\u003c/p\u003e\u003c/body\u003e\u003c/html\u003e\", auth.AccessToken)\n\t}))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinburke%2Fgoogle-oauth-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinburke%2Fgoogle-oauth-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinburke%2Fgoogle-oauth-handler/lists"}