{"id":21654433,"url":"https://github.com/hvalfangst/google-oauth2-authorization-code-flow","last_synced_at":"2026-04-13T05:36:53.626Z","repository":{"id":201227178,"uuid":"705344393","full_name":"hvalfangst/google-oauth2-authorization-code-flow","owner":"hvalfangst","description":"This project provides a basic example in which OAuth2 authorization code flow is being utilized in order to access Google resources on behalf of the user.  User and token information is persisted to DB upon successful authorization.","archived":false,"fork":false,"pushed_at":"2023-10-19T14:45:16.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-25T06:25:12.178Z","etag":null,"topics":["docker","docker-compose","gin-gonic","go-pg","golang","google","oauth2"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hvalfangst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-15T18:49:12.000Z","updated_at":"2024-10-14T21:42:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"8c3bf8c1-f9fc-4149-a070-1327659a356e","html_url":"https://github.com/hvalfangst/google-oauth2-authorization-code-flow","commit_stats":null,"previous_names":["hvalfangst/oauth2-authorization-code-flow-using-google","hvalfangst/google-oauth2-authorization-code-flow"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvalfangst%2Fgoogle-oauth2-authorization-code-flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvalfangst%2Fgoogle-oauth2-authorization-code-flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvalfangst%2Fgoogle-oauth2-authorization-code-flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hvalfangst%2Fgoogle-oauth2-authorization-code-flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hvalfangst","download_url":"https://codeload.github.com/hvalfangst/google-oauth2-authorization-code-flow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554120,"owners_count":20471173,"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":["docker","docker-compose","gin-gonic","go-pg","golang","google","oauth2"],"created_at":"2024-11-25T08:27:52.080Z","updated_at":"2025-12-31T00:08:46.855Z","avatar_url":"https://github.com/hvalfangst.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OAuth2-authorization-flow-using-Google\n\n## Abstract\nThis project provides a basic example in which OAuth2 authorization code flow is being utilized in order to access Google resources on behalf of the user. \nUser and token information is persisted to DB upon successful authorization.\n\n\n## Requirements\n\n* x86-64\n* Linux/Unix\n* [Golang](https://go.dev/)\n* [Docker](https://www.docker.com/products/docker-desktop/)\n* [Google account](https://accounts.google.com/signup/v2/createaccount?theme=glif\u0026flowName=GlifWebSignIn\u0026flowEntry=SignUp)\n\n\n## OAuth2 Credentials\n\nFor this project to work, you need to replace the 'PLACEHOLDER' values associated with keys \"ClientID\" and \"ClientSecret\" in file 'configuration.json'.\n\nIn order to get hold of Client ID and Secret, one must do the following:\n\n1. Access the [credentials section](https://console.cloud.google.com/apis/credentials) under Google APIs \u0026 Services. Create a new project if you haven't done so already.\n2. Click on the button with label 'CREATE CREDENTIALS'\n3. Choose option 'OAuth client ID'\n4. Choose option 'Web application'\n5. Add the following under 'Authorized redirect URIs': http://localhost:8080/auth/google/callback\n6. Click on the 'CREATE' button\n\nNow you can replace fields contained in file 'configuration.json' with your actual ID \u0026 Secret\n\n## Application Flow\n\n1. User visits the (static HTML) login page by accessing the following URL in the browser: http://localhost:8080\n2. User clicks on the \"Login with Google\" button, which redirects to http://localhost:8080/auth/google/login \n3. The application initiates the OAuth2 Authorization Code Flow, redirecting users to Google's authentication page.\n4. Users log in to their Google accounts and authorize the application to access their Google account information.\n5. Upon successful authorization, Google sends an authorization code to the application's callback URL at http://localhost:8080/auth/google/callback\n6. The application exchanges the authorization code contained in callback response for an access token and other necessary credentials.\n7. The access token is used to make requests to Google's UserInfo API, which in this case retrieves email associated with user.\n8. The application persists a record containing the user's access token in DB.\n\n\n## Startup\n\nThe script \"up\" provisions resources and starts our application by executing the following:\n```\n1. docker-compose -f docker/db/docker-compose.yml up -d\n2. go build -o OAuth2-authorization-code-flow-using-Google src/main.go\n3. ./OAuth2-authorization-code-flow-using-Google\n```\n\n## Shutdown\n\nThe script \"down\" deletes our dev and test databases by executing the following:\n```\n1. docker-compose -f db/docker-compose.yml down\n```\n\n## Postman Collection\n\nThe repository includes a Postman collection in the 'postman' directory.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhvalfangst%2Fgoogle-oauth2-authorization-code-flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhvalfangst%2Fgoogle-oauth2-authorization-code-flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhvalfangst%2Fgoogle-oauth2-authorization-code-flow/lists"}