diff --git a/pkg/clients/key_flow.go b/pkg/clients/key_flow.go index 7e274952..e5fe312f 100644 --- a/pkg/clients/key_flow.go +++ b/pkg/clients/key_flow.go @@ -173,13 +173,13 @@ func (c *KeyFlow) Do(req *http.Request) (*http.Response, error) { func (c *KeyFlow) GetAccessToken() (string, error) { accessTokenIsValid, err := c.validateToken(c.token.AccessToken) if err != nil { - return "", errors.Wrap(err, "failed initial validation") + return "", errors.Wrap(err, "failed to validate existing keyflow token") } if accessTokenIsValid { return c.token.AccessToken, nil } if err := c.recreateAccessToken(); err != nil { - return "", errors.Wrap(err, "failed during token recreation") + return "", errors.Wrap(err, "failed to recreate keyflow token") } return c.token.AccessToken, nil } @@ -378,6 +378,9 @@ func (c *KeyFlow) validateToken(token string) (bool, error) { return false, nil } if _, err := c.parseToken(token); err != nil { + if strings.Contains(err.Error(), "401") { + return false, nil + } return false, err } return true, nil