go-oauth2 / oauth2

OAuth 2.0 server library for the Go programming language.
https://pkg.go.dev/github.com/go-oauth2/oauth2/v4
MIT License
3.31k stars 563 forks source link

Can we use post token endpoint as password grant instead of get method? #227

Closed meysamhadeli closed 1 year ago

meysamhadeli commented 1 year ago

I wanna call this this endpoint for retrieve token. By default, the Get method is considered. Can you use Post method? It's work's correctly with Get method. but I don't want pass my information as query string!

    http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
        srv.HandleTokenRequest(w, r)
    })

this is my endpoint as Post method: http://localhost:9096/token this is my body parameters:

{
    "grant_type":"password",
    "client_id":"clientId",
    "client_secret":"clientSecret",
    "scope":"all",
    "username":"test",
    "password":"test"
}

Thanks for helping :)

jarlandre commented 1 year ago
srv.SetAllowGetAccessRequest(false)
srv.SetClientInfoHandler(server.ClientFormHandler)
srv.SetPasswordAuthorizationHandler(.......)