Skip to content

Commit

Permalink
feat(request): trigger token generation if missing
Browse files Browse the repository at this point in the history
Verify if the current client has a token, if not, try to generate one

Signed-off-by: Salim Afiune Maya <[email protected]>
  • Loading branch information
afiune committed Mar 9, 2020
1 parent d61701d commit 8cd82d6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ func (c *client) NewRequest(method string, apiURL string, body io.Reader) (*http
if apiURL == apiTokens {
headers["X-LW-UAKS"] = c.auth.secret
} else {
// verify that the client has a token, if not, try to generate one
if c.auth.token == "" {
if _, err = c.GenerateToken(); err != nil {
return nil, err
}
}
headers["Authorization"] = c.auth.token
}

Expand Down

0 comments on commit 8cd82d6

Please sign in to comment.