Skip to content

Instantly share code, notes, and snippets.

@cheikhsimsol
Last active February 7, 2024 21:52
Show Gist options
  • Save cheikhsimsol/27ca8ec5f8ac55b1cd1b6106bf5b18c2 to your computer and use it in GitHub Desktop.
Save cheikhsimsol/27ca8ec5f8ac55b1cd1b6106bf5b18c2 to your computer and use it in GitHub Desktop.
...
func main() {
mux := http.NewServeMux()
conf := &oauth2.Config{
ClientID: "RANDOM",
ClientSecret: "RANDOM",
Scopes: []string{"offline_access"},
Endpoint: oauth2.Endpoint{
TokenURL: "https://oauth.wiremockapi.cloud/oauth/token",
AuthURL: "https://oauth.wiremockapi.cloud/oauth/authorize",
},
RedirectURL: "http://localhost:8080/consume",
}
// Map a route to handle requests to the root path ("/")
mux.HandleFunc("GET /login", func(w http.ResponseWriter, r *http.Request) {
// section to redirect user
url := conf.AuthCodeURL("state", oauth2.AccessTypeOffline)
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
})
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment