{"id":25668458,"url":"https://github.com/borud/gin","last_synced_at":"2025-07-08T23:03:26.664Z","repository":{"id":57532542,"uuid":"279113922","full_name":"borud/gin","owner":"borud","description":"Simple Google Login","archived":false,"fork":false,"pushed_at":"2020-07-24T21:43:02.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T23:03:23.313Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/borud.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":"2020-07-12T17:26:53.000Z","updated_at":"2023-10-30T13:52:31.000Z","dependencies_parsed_at":"2022-09-26T18:22:06.648Z","dependency_job_id":null,"html_url":"https://github.com/borud/gin","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/borud/gin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fgin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fgin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fgin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fgin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/borud","download_url":"https://codeload.github.com/borud/gin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/borud%2Fgin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264363744,"owners_count":23596501,"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":[],"created_at":"2025-02-24T10:34:01.895Z","updated_at":"2025-07-08T23:03:26.637Z","avatar_url":"https://github.com/borud.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Google Login\n\n[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/borud/gin/pkg/auth)\n\n**This is a work in progress.**\n\nI got tired of baroque libraries that pull inn all manner of unwanted\ncruft so I made a bare bones library to log in using Google. This code\ntakes care of only the Google login.  \n\nImport the following package\n\n    \"github.com/borud/gin/pkg/auth\"\n\n## Abbreviated example\n\nHere is an abbreviated example of how to use this module.  The\n`loginCallback` is where you would create the session etc, but since\npeople use different libraries for handling sessions we leave this\npart up to you.\n\n    package main\n    \n    import (\n    \t\"fmt\"\n    \t\"net/http\"\n    \t\"os\"\n    \n    \t\"github.com/borud/gin/pkg/auth\"\n    )\n    \n    func main() {\n    \tgoogleAuth := auth.New(\u0026auth.GoogleAuthConfig{\n    \t\tClientID:      os.Getenv(\"GOOGLE_CLIENT_ID\"),\n    \t\tClientSecret:  os.Getenv(\"GOOGLE_CLIENT_SECRET\"),\n    \t\tCallbackURL:   \"http://localhost:3000/google/callback\",\n    \t\tLoginCallback: loginCallback,\n    \t})\n    \n    \thttp.HandleFunc(\"/google/login\", googleAuth.GoogleLoginHandler)\n    \thttp.HandleFunc(\"/google/callback\", googleAuth.GoogleCallbackHandler)\n    \thttp.ListenAndServe(\":3000\", nil)\n    }\n    \n    func loginCallback(w http.ResponseWriter, r *http.Request, userinfo *auth.Userinfo) {\n    \thtml := `Hello %s\u003cp\u003e\u003cimg src=\"%s\"`\n    \tw.Header().Set(\"Content-Type\", \"text/html; charset=utf-8\")\n    \tfmt.Fprintf(w, html, userinfo.Name, userinfo.Picture)\n    }\n        \n\nPlease see the [example.go](example.go) file for a more complete example.\n\n\n## Session management\n\nYou have to do your own session creation and management.  You can do\nthis by implementing your own callback of the following type:\n\n    type LoginFunc func(w http.ResponseWriter, r *http.Request, u *Userinfo)\n\t\nThe `Userinfo` struct that is provided contains the following fields:\n\n    type Userinfo struct {\n    \tID            string `json:\"id\"`\n    \tEmail         string `json:\"email\"`\n    \tVerifiedEmail bool   `json:\"verified_email\"`\n    \tName          string `json:\"name\"`\n    \tGivenName     string `json:\"given_name\"`\n    \tFamilyName    string `json:\"family_name\"`\n    \tPicture       string `json:\"picture\"`\n    \tLocale        string `json:\"locale\"`\n    \tHostDomain    string `json:\"hd\"`\n    }\n\n\n## Providing credentials\nThis assumes you have your credentials in the environment, so make\nsure you have the following environment variables set.\n\n    GOOGLE_CLIENT_ID=\u003cyour client id\u003e\n\tGOOGLE_CLIENT_SECRET=\u003cyour client secret\u003e\n\nYou can create your client credentials at:\nhttps://console.developers.google.com/apis/credentials\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborud%2Fgin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fborud%2Fgin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fborud%2Fgin/lists"}