Skip to content

Commit

Permalink
fix(alpacabkfeeder): use basic auth for sandbox endpoints (#578)
Browse files Browse the repository at this point in the history
* fix(alpacabkfeeder): add a logic for sandbox endpoints
  • Loading branch information
dakimura authored Mar 16, 2022
1 parent f594c2c commit 3d0a0d4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions contrib/alpacabkfeeder/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ func defaultDo(c *Client, req *http.Request) (*http.Response, error) {
if c.credentials.OAuth != "" {
req.Header.Set("Authorization", "Bearer "+c.credentials.OAuth)
} else {
req.Header.Set("APCA-API-KEY-ID", c.credentials.ID)
req.Header.Set("APCA-API-SECRET-KEY", c.credentials.Secret)
// Add Basic Auth
req.SetBasicAuth(c.credentials.ID, c.credentials.Secret)
if strings.Contains(req.URL.String(), "sandbox"){
// Add Basic Auth
req.SetBasicAuth(c.credentials.ID, c.credentials.Secret)
}else {
req.Header.Set("APCA-API-KEY-ID", c.credentials.ID)
req.Header.Set("APCA-API-SECRET-KEY", c.credentials.Secret)
}
}

client := &http.Client{
Expand Down

0 comments on commit 3d0a0d4

Please sign in to comment.