go-oauth2

module
v0.0.0-...-edd856d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2016 License: MIT

README

README

go-oauth2 provides a thin wrapper of golang.org/x/oauth2. This currently supports four providers, GitHub, Facebook, Google and Slack.

See an example

Here is the essence.

Initilization.

oauth2.WithProviders(
	github.New(oauth2.NewConfig(oauth2.GITHUB, "http://localhost:8080/auth/callback/"+oauth2.GITHUB)),
)

Redirecting to provider page.

loginURL := oauth2.ProviderByName(provider).Config().AuthCodeURL("state")
w.Header().Set("Location", loginURL)
w.WriteHeader(http.StatusTemporaryRedirect)

Retrieving profile.

p := oauth2.ProviderByName(provider)
u, _:= oauth2.ProfileByCode(p, r.FormValue("code"))
log.Println("Name", u.Name())
// use u.Token() ...

License

MIT License

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL