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