forked from remote/oauth2
clientcredentials: add option for additional endpoint parameters
This is to support https://auth0.com/docs/api-auth/config/asking-for-access-tokens. Fixes https://github.com/golang/oauth2/issues/216 Change-Id: I9b8fdb4fe22c688fd71e43bd21d80b796434b8b0 Reviewed-on: https://go-review.googlesource.com/36880 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Jaana Burcu Dogan <jbd@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Jaana Burcu Dogan
parent
efb10a3061
commit
01b79d9447
@@ -9,15 +9,17 @@ import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func newConf(url string) *Config {
|
||||
func newConf(serverURL string) *Config {
|
||||
return &Config{
|
||||
ClientID: "CLIENT_ID",
|
||||
ClientSecret: "CLIENT_SECRET",
|
||||
Scopes: []string{"scope1", "scope2"},
|
||||
TokenURL: url + "/token",
|
||||
ClientID: "CLIENT_ID",
|
||||
ClientSecret: "CLIENT_SECRET",
|
||||
Scopes: []string{"scope1", "scope2"},
|
||||
TokenURL: serverURL + "/token",
|
||||
EndpointParams: url.Values{"audience": {"audience1"}},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +50,7 @@ func TestTokenRequest(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("failed reading request body: %s.", err)
|
||||
}
|
||||
if string(body) != "grant_type=client_credentials&scope=scope1+scope2" {
|
||||
if string(body) != "audience=audience1&grant_type=client_credentials&scope=scope1+scope2" {
|
||||
t.Errorf("payload = %q; want %q", string(body), "grant_type=client_credentials&scope=scope1+scope2")
|
||||
}
|
||||
w.Header().Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
@@ -84,7 +86,7 @@ func TestTokenRefreshRequest(t *testing.T) {
|
||||
t.Errorf("Unexpected Content-Type header, %v is found.", headerContentType)
|
||||
}
|
||||
body, _ := ioutil.ReadAll(r.Body)
|
||||
if string(body) != "grant_type=client_credentials&scope=scope1+scope2" {
|
||||
if string(body) != "audience=audience1&grant_type=client_credentials&scope=scope1+scope2" {
|
||||
t.Errorf("Unexpected refresh token payload, %v is found.", string(body))
|
||||
}
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user