include AuthOptions in ReauthFunc closure
diff --git a/openstack/client.go b/openstack/client.go
index 55c298c..6818d9d 100644
--- a/openstack/client.go
+++ b/openstack/client.go
@@ -58,7 +58,6 @@
if err != nil {
return nil, err
}
-
return client, nil
}
@@ -109,8 +108,9 @@
}
if options.AllowReauth {
- client.ReauthFunc = AuthenticateV2
- client.AuthOptions = options
+ client.ReauthFunc = func() error {
+ return AuthenticateV2(client, options)
+ }
}
client.TokenID = token.ID
client.EndpointLocator = func(opts gophercloud.EndpointOpts) (string, error) {
@@ -139,8 +139,9 @@
client.TokenID = token.ID
if options.AllowReauth {
- client.ReauthFunc = AuthenticateV3
- client.AuthOptions = options
+ client.ReauthFunc = func() error {
+ return AuthenticateV3(client, options)
+ }
}
client.EndpointLocator = func(opts gophercloud.EndpointOpts) (string, error) {
return V3EndpointURL(v3Client, opts)
diff --git a/provider_client.go b/provider_client.go
index 1eafbd2..200ee0b 100644
--- a/provider_client.go
+++ b/provider_client.go
@@ -64,15 +64,10 @@
// UserAgent represents the User-Agent header in the HTTP request.
UserAgent UserAgent
- // AuthOptions is the user-provided options for authentication. This will be empty
- // unless gophercloud.AuthOption.AllowReauth is set to true. This will be
- // passed to ReauthFunc for re-authenticating when a user's token expires.
- AuthOptions AuthOptions
-
// ReauthFunc is the function used to re-authenticate the user if the request
// fails with a 401 HTTP response code. This a needed because there may be multiple
// authentication functions for different Identity service versions.
- ReauthFunc func(client *ProviderClient, options AuthOptions) error
+ ReauthFunc func() error
}
// AuthenticatedHeaders returns a map of HTTP headers that are common for all
@@ -189,9 +184,9 @@
return nil, err
}
- if resp.StatusCode == 401 {
- if client.AuthOptions.AllowReauth {
- err = client.ReauthFunc(client, client.AuthOptions)
+ if resp.StatusCode == http.StatusUnauthorized {
+ if client.ReauthFunc != nil {
+ err = client.ReauthFunc()
if err != nil {
return nil, fmt.Errorf("Error trying to re-authenticate: %s", err)
}
diff --git a/rackspace/client.go b/rackspace/client.go
index 003683f..8f1f34f 100644
--- a/rackspace/client.go
+++ b/rackspace/client.go
@@ -49,7 +49,6 @@
if err != nil {
return nil, err
}
-
return client, nil
}
@@ -98,8 +97,9 @@
}
if options.AllowReauth {
- client.ReauthFunc = AuthenticateV2
- client.AuthOptions = options
+ client.ReauthFunc = func() error {
+ return AuthenticateV2(client, options)
+ }
}
client.TokenID = token.ID
client.EndpointLocator = func(opts gophercloud.EndpointOpts) (string, error) {