Shuffle around authentication methods.
I'd like to be able to explicitly authenticated with a certain version.
diff --git a/openstack/identity/v3/client.go b/openstack/identity/v3/client.go
index 984d03e..96e6f5d 100644
--- a/openstack/identity/v3/client.go
+++ b/openstack/identity/v3/client.go
@@ -20,17 +20,17 @@
}
// NewClient creates a new client associated with the v3 identity service of a provider.
-func NewClient(provider *gophercloud.ProviderClient) *Client {
+func NewClient(provider *gophercloud.ProviderClient, endpoint string) *Client {
return &Client{
ServiceClient: gophercloud.ServiceClient{
ProviderClient: *provider,
- Endpoint: provider.IdentityEndpoint,
+ Endpoint: endpoint,
},
}
}
-// Authenticate provides the supplied credentials to an identity v3 endpoint and attempts to acquire a token.
-func (c *Client) Authenticate(authOptions gophercloud.AuthOptions) (*Token, error) {
+// GetToken provides the supplied credentials to an identity v3 endpoint and attempts to acquire a token.
+func (c *Client) GetToken(authOptions gophercloud.AuthOptions) (*Token, error) {
c.ServiceClient.ProviderClient.Options = authOptions
result, err := tokens.Create(&c.ServiceClient, nil)
@@ -48,8 +48,5 @@
return nil, err
}
- return &Token{
- ID: tokenID,
- ExpiresAt: expiresAt,
- }, nil
+ return &Token{ID: tokenID, ExpiresAt: expiresAt}, nil
}
diff --git a/openstack/identity/v3/client_test.go b/openstack/identity/v3/client_test.go
index c9cf3c2..6747660 100644
--- a/openstack/identity/v3/client_test.go
+++ b/openstack/identity/v3/client_test.go
@@ -26,7 +26,7 @@
}
}
-func TestAuthentication(t *testing.T) {
+func TestGetToken(t *testing.T) {
testhelper.SetupHTTP()
defer testhelper.TeardownHTTP()
const ID = "aaaa1111"
@@ -43,7 +43,7 @@
}
client := NewClient(provider)
- token, err := client.Authenticate(gophercloud.AuthOptions{UserID: "me", Password: "swordfish"})
+ token, err := client.GetToken(gophercloud.AuthOptions{UserID: "me", Password: "swordfish"})
if err != nil {
t.Errorf("Unexpected error from authentication: %v", err)
}