oauth2: rename SetParam to SetAuthURLParam
SetParam is quite vague to represent an Option that sets the auth
URL query parameters. Renaming it for explicitness.
Fixes #108.
Change-Id: Ic9f0181097820ee83404c9432451d71658dd8c67
Reviewed-on: https://go-review.googlesource.com/8491
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/oauth2.go b/oauth2.go
index 0c6a1ed..98b3c2c 100644
--- a/oauth2.go
+++ b/oauth2.go
@@ -79,13 +79,13 @@
// result in your application obtaining a refresh token the
// first time your application exchanges an authorization
// code for a user.
- AccessTypeOnline AuthCodeOption = SetParam("access_type", "online")
- AccessTypeOffline AuthCodeOption = SetParam("access_type", "offline")
+ AccessTypeOnline AuthCodeOption = SetAuthURLParam("access_type", "online")
+ AccessTypeOffline AuthCodeOption = SetAuthURLParam("access_type", "offline")
// ApprovalForce forces the users to view the consent dialog
// and confirm the permissions request at the URL returned
// from AuthCodeURL, even if they've already done so.
- ApprovalForce AuthCodeOption = SetParam("approval_prompt", "force")
+ ApprovalForce AuthCodeOption = SetAuthURLParam("approval_prompt", "force")
)
// An AuthCodeOption is passed to Config.AuthCodeURL.
@@ -97,9 +97,9 @@
func (p setParam) setValue(m url.Values) { m.Set(p.k, p.v) }
-// SetParam builds an AuthCodeOption which passes key/value parameters
+// SetAuthURLParam builds an AuthCodeOption which passes key/value parameters
// to a provider's authorization endpoint.
-func SetParam(key, value string) AuthCodeOption {
+func SetAuthURLParam(key, value string) AuthCodeOption {
return setParam{key, value}
}
diff --git a/oauth2_test.go b/oauth2_test.go
index 0bc6129..7b7e3c1 100644
--- a/oauth2_test.go
+++ b/oauth2_test.go
@@ -63,7 +63,7 @@
func TestAuthCodeURL_CustomParam(t *testing.T) {
conf := newConf("server")
- param := SetParam("foo", "bar")
+ param := SetAuthURLParam("foo", "bar")
url := conf.AuthCodeURL("baz", param)
if url != "server/auth?client_id=CLIENT_ID&foo=bar&redirect_uri=REDIRECT_URL&response_type=code&scope=scope1+scope2&state=baz" {
t.Errorf("Auth code URL doesn't match the expected, found: %v", url)