webapps URL

This commit is contained in:
Aliaksandr Pliutau 2015-11-17 10:03:46 +07:00
parent 3d924aeaf4
commit 2f016eafbb
2 changed files with 5 additions and 5 deletions

View File

@ -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
}

View File

@ -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)
}
}