Last active
February 7, 2024 21:52
-
-
Save cheikhsimsol/27ca8ec5f8ac55b1cd1b6106bf5b18c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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