Skip to content

Commit

Permalink
fix token renew (#12)
Browse files Browse the repository at this point in the history
* fix token renew

* wrong if
  • Loading branch information
dbeneker authored Jun 15, 2021
1 parent 868e00b commit 3b45260
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ func (c *Client) Request(method string, path []string, body, response interface{
}

resp, err := c.RawRequest(r)
if err != nil {
return errors.Wrap(err, "request failed")
}

if resp.StatusCode == http.StatusForbidden && c.auth != nil && !opts.SkipRenewal {
if resp != nil && resp.StatusCode == http.StatusForbidden && c.auth != nil && !opts.SkipRenewal {
_ = resp.Body.Close()

err = c.renewToken()
Expand All @@ -131,6 +127,8 @@ func (c *Client) Request(method string, path []string, body, response interface{
if err != nil {
return errors.Wrap(err, "request with new token failed")
}
} else if err != nil {
return errors.Wrap(err, "request failed")
}
defer resp.Body.Close()

Expand Down

0 comments on commit 3b45260

Please sign in to comment.