Authenticate by creating an identity/v3 Client.
diff --git a/openstack/identity/v3/client.go b/openstack/identity/v3/client.go
index 164958f..0647471 100644
--- a/openstack/identity/v3/client.go
+++ b/openstack/identity/v3/client.go
@@ -1,17 +1,13 @@
package v3
-import "github.com/rackspace/gophercloud"
+import (
+ "github.com/rackspace/gophercloud"
+ "github.com/rackspace/gophercloud/openstack/identity/v3/tokens"
+)
// Client abstracts the connection information necessary to make API calls to Identity v3
// resources.
-type Client struct {
- gophercloud.ServiceClient
-
- // TokenID is redudant storage for an active token.
- // The Identity service occasionally needs to access the assigned token directly, but I don't want to export it from all
- // service clients unless we absolutely need to.
- TokenID string
-}
+type Client gophercloud.ServiceClient
var (
nilClient = Client{}
@@ -20,5 +16,14 @@
// NewClient attempts to authenticate to the v3 identity endpoint. Returns a populated
// IdentityV3Client on success or an error on failure.
func NewClient(authOptions gophercloud.AuthOptions) (*Client, error) {
- return &nilClient, nil
+ client := Client{Options: authOptions}
+
+ result, err := tokens.Create(&client, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ // Assign the token and return.
+ client.TokenID = result.TokenID()
+ return &client, nil
}