{"id":18446678,"url":"https://github.com/cristalhq/oauth2","last_synced_at":"2025-04-08T00:31:56.235Z","repository":{"id":57499850,"uuid":"212260511","full_name":"cristalhq/oauth2","owner":"cristalhq","description":"OAuth2 client in Go","archived":false,"fork":false,"pushed_at":"2024-03-05T11:29:39.000Z","size":65,"stargazers_count":22,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T03:24:49.721Z","etag":null,"topics":["authentication","dependency-free","go","golang","oauth2","oauth2-client"],"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/cristalhq.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-02T05:14:32.000Z","updated_at":"2023-11-29T16:03:59.000Z","dependencies_parsed_at":"2024-06-19T20:02:49.655Z","dependency_job_id":null,"html_url":"https://github.com/cristalhq/oauth2","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Foauth2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Foauth2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Foauth2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cristalhq%2Foauth2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cristalhq","download_url":"https://codeload.github.com/cristalhq/oauth2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755407,"owners_count":20990617,"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":["authentication","dependency-free","go","golang","oauth2","oauth2-client"],"created_at":"2024-11-06T07:10:00.779Z","updated_at":"2025-04-08T00:31:55.936Z","avatar_url":"https://github.com/cristalhq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# oauth2\n\n[![build-img]][build-url]\n[![pkg-img]][pkg-url]\n[![reportcard-img]][reportcard-url]\n[![coverage-img]][coverage-url]\n[![version-img]][version-url]\n\nOAuth2 client for Go.\n\n## Features\n\n* Simple API.\n* Tiny codebase.\n* Dependency-free.\n\nSee [GUIDE.md](https://github.com/cristalhq/oauth2/blob/main/GUIDE.md) for more details.\n\n## Install\n\nGo version 1.17\n\n```\ngo get github.com/cristalhq/oauth2\n```\n\n## Example\n\n```go\nconfig := oauth2.Config{\n    ClientID:     \"YOUR_CLIENT_ID\",\n    ClientSecret: \"YOUR_CLIENT_SECRET\",\n    AuthURL:      \"https://provider.com/o/oauth2/auth\",\n    TokenURL:     \"https://provider.com/o/oauth2/token\",\n    Scopes:       []string{\"email\", \"avatar\"},\n}\n\n// create a client\nclient := oauth2.NewClient(http.DefaultClient, config)\n\n// url to fetch the code\nurl := client.AuthCodeURL(\"state\")\nfmt.Printf(\"Visit the URL with the auth dialog: %v\", url)\n\n// Use the authorization code that is pushed to the redirect URL.\n// Exchange will do the handshake to retrieve the initial access token.\nvar code string\nif _, err := fmt.Scan(\u0026code); err != nil {\n    panic(err)\n}\n\n// get a token\ntoken, err := client.Exchange(context.Background(), code)\nif err != nil {\n    panic(err)\n}\n\nvar _ string = token.AccessToken  // OAuth2 token\nvar _ string = token.TokenType    // type of the token\nvar _ string = token.RefreshToken // token for a refresh\nvar _ time.Time = token.Expiry    // token expiration time\nvar _ bool = token.IsExpired()    // have token expired?\n```\n\nAlso see examples: [example_test.go](https://github.com/cristalhq/oauth2/blob/main/example_test.go).\n\n## Documentation\n\nSee [these docs][pkg-url].\n\n## License\n\n[MIT License](LICENSE).\n\n[build-img]: https://github.com/cristalhq/oauth2/workflows/build/badge.svg\n[build-url]: https://github.com/cristalhq/oauth2/actions\n[pkg-img]: https://pkg.go.dev/badge/cristalhq/oauth2\n[pkg-url]: https://pkg.go.dev/github.com/cristalhq/oauth2\n[reportcard-img]: https://goreportcard.com/badge/cristalhq/oauth2\n[reportcard-url]: https://goreportcard.com/report/cristalhq/oauth2\n[coverage-img]: https://codecov.io/gh/cristalhq/oauth2/branch/master/graph/badge.svg\n[coverage-url]: https://codecov.io/gh/cristalhq/oauth2\n[version-img]: https://img.shields.io/github/v/release/cristalhq/oauth2\n[version-url]: https://github.com/cristalhq/oauth2/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Foauth2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcristalhq%2Foauth2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcristalhq%2Foauth2/lists"}