Parse token expiration from the response.
diff --git a/openstack/identity/v3/tokens/results.go b/openstack/identity/v3/tokens/results.go
index 0f44744..9f0d623 100644
--- a/openstack/identity/v3/tokens/results.go
+++ b/openstack/identity/v3/tokens/results.go
@@ -10,3 +10,28 @@
func (r *TokenCreateResult) TokenID() (string, error) {
return r.tokenID, nil
}
+
+// ExpiresAt retrieves the token expiration time.
+func (r *TokenCreateResult) ExpiresAt() (time.Time, error) {
+ type tokenResp struct {
+ ExpiresAt string `mapstructure:"expires_at"`
+ }
+
+ type response struct {
+ Token tokenResp `mapstructure:"token"`
+ }
+
+ var resp response
+ err := mapstructure.Decode(r.response, &resp)
+ if err != nil {
+ return time.Time{}, err
+ }
+
+ // Attempt to parse the timestamp.
+ ts, err := time.Parse(RFC3339Milli, resp.Token.ExpiresAt)
+ if err != nil {
+ return time.Time{}, err
+ }
+
+ return ts, nil
+}