diff --git a/api/logical.go b/api/logical.go index 9753e9668f..d862438d44 100644 --- a/api/logical.go +++ b/api/logical.go @@ -119,9 +119,13 @@ func (c *Logical) Delete(path string) (*Secret, error) { func (c *Logical) Unwrap(wrappingToken string) (*Secret, error) { var data map[string]interface{} - if wrappingToken != "" && wrappingToken != c.c.Token() { - data = map[string]interface{}{ - "token": wrappingToken, + if wrappingToken != "" { + if c.c.Token() == "" { + c.c.SetToken(wrappingToken) + } else if wrappingToken != c.c.Token() { + data = map[string]interface{}{ + "token": wrappingToken, + } } }