From 2f016eafbbc139ece608e603ec3d2e4576b8ea6b Mon Sep 17 00:00:00 2001 From: Aliaksandr Pliutau Date: Tue, 17 Nov 2015 10:03:46 +0700 Subject: [PATCH] webapps URL --- auth.go | 2 +- auth_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auth.go b/auth.go index 526c16e..5beada8 100644 --- a/auth.go +++ b/auth.go @@ -20,7 +20,7 @@ func (c *Client) GetAuthorizationCodeURL(redirectURI string, scopes []string) (s scopes = []string{"profile", "email"} } - return c.APIBase + "/webapps/auth/protocol/openidconnect/v1/authorize?client_id=" + + return strings.Replace(c.APIBase, "api.", "", -1) + "/webapps/auth/protocol/openidconnect/v1/authorize?client_id=" + url.QueryEscape(c.ClientID) + "&response_type=code&scope=" + strings.Join(scopes, "+") + "&redirect_uri=" + url.QueryEscape(redirectURI), nil } diff --git a/auth_test.go b/auth_test.go index 031c40f..4cadc5c 100644 --- a/auth_test.go +++ b/auth_test.go @@ -13,13 +13,13 @@ func TestGetAuthorizationCodeURL(t *testing.T) { } uri, err := c.GetAuthorizationCodeURL("test", []string{}) - if uri != "https://api.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=profile+email&redirect_uri=test" { - t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test") + if uri != "https://sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=profile+email&redirect_uri=test" { + t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test " + uri) } uri, err = c.GetAuthorizationCodeURL("test", []string{"address"}) - if uri != "https://api.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=address&redirect_uri=test" { - t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test and scope=address") + if uri != "https://sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=clid&response_type=code&scope=address&redirect_uri=test" { + t.Errorf("GetAuthorizationCodeURL returns incorrect value for redirectURI=test and scope=address " + uri) } }