KO
|
EN
gitlite — search
Search
#javascript
#python
#hacktoberfest
#react
#ai
#typescript
#llm
#go
#golang
#android
#machine-learning
#rust
#deep-learning
#linux
oauth2
★ 22
Open GitHub ↗
OAuth2 client in Go
Download README (.md)
Explore Similar Repositories
ply_tools
:
Addon that adds new operators to the Blender 2.8x context menu, for instance the Origin to Selection operator.
modeltools
:
GO语言连接Mysql生成对应的model,包括对应字段类型、注释等。生成基础的结构体,不局限于某一个ORM。
unlzexe
:
Utility to decompress EXE files that are compressed with LZEXE Ver. 0.90/0.91
Flutter-Bloc-Example
:
How to architect Flutter Code according to BLoC Pattern.
pas2dart
:
Object Pascal (Free Pascal 3, Delphi 2007) to Dart (2.5) transpiler
// repository documentation
Was this content helpful?
★ 0
(0 ratings)
Select Rating:
★
★
★
★
★
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
oauth2
?
Download (.md)
# oauth2 [![build-img]][build-url] [![pkg-img]][pkg-url] [![reportcard-img]][reportcard-url] [![coverage-img]][coverage-url] [![version-img]][version-url] OAuth2 client for Go. ## Features * Simple API. * Tiny codebase. * Dependency-free. See [GUIDE.md](https://github.com/cristalhq/oauth2/blob/main/GUIDE.md) for more details. ## Install Go version 1.17 ``` go get github.com/cristalhq/oauth2 ``` ## Example ```go config := oauth2.Config{ ClientID: "YOUR_CLIENT_ID", ClientSecret: "YOUR_CLIENT_SECRET", AuthURL: "https://provider.com/o/oauth2/auth", TokenURL: "https://provider.com/o/oauth2/token", Scopes: []string{"email", "avatar"}, } // create a client client := oauth2.NewClient(http.DefaultClient, config) // url to fetch the code url := client.AuthCodeURL("state") fmt.Printf("Visit the URL with the auth dialog: %v", url) // Use the authorization code that is pushed to the redirect URL. // Exchange will do the handshake to retrieve the initial access token. var code string if _, err := fmt.Scan(&code); err != nil { panic(err) } // get a token token, err := client.Exchange(context.Background(), code) if err != nil { panic(err) } var _ string = token.AccessToken // OAuth2 token var _ string = token.TokenType // type of the token var _ string = token.RefreshToken // token for a refresh var _ time.Time = token.Expiry // token expiration time var _ bool = token.IsExpired() // have token expired? ``` Also see examples: [example_test.go](https://github.com/cristalhq/oauth2/blob/main/example_test.go). ## Documentation See [these docs][pkg-url]. ## License [MIT License](LICENSE). [build-img]: https://github.com/cristalhq/oauth2/workflows/build/badge.svg [build-url]: https://github.com/cristalhq/oauth2/actions [pkg-img]: https://pkg.go.dev/badge/cristalhq/oauth2 [pkg-url]: https://pkg.go.dev/github.com/cristalhq/oauth2 [reportcard-img]: https://goreportcard.com/badge/cristalhq/oauth2 [reportcard-url]: https://goreportcard.com/report/cristalhq/oauth2 [coverage-img]: https://codecov.io/gh/cristalhq/oauth2/branch/master/graph/badge.svg [coverage-url]: https://codecov.io/gh/cristalhq/oauth2 [version-img]: https://img.shields.io/github/v/release/cristalhq/oauth2 [version-url]: https://github.com/cristalhq/oauth2/releases