mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 16:26:57 +08:00
fix: use auth query parameter instead of Authorization header for Lighter API
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"nofx/logger"
|
"nofx/logger"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@@ -100,15 +101,18 @@ func (t *LighterTraderV2) GetOrderStatus(symbol string, orderID string) (map[str
|
|||||||
return nil, fmt.Errorf("invalid auth token: %w", err)
|
return nil, fmt.Errorf("invalid auth token: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build request URL
|
// URL encode auth token (contains colons that need encoding)
|
||||||
endpoint := fmt.Sprintf("%s/api/v1/order/%s", t.baseURL, orderID)
|
// Authentication: Use "auth" query parameter (not Authorization header)
|
||||||
|
encodedAuth := url.QueryEscape(t.authToken)
|
||||||
|
|
||||||
|
// Build request URL with auth query parameter
|
||||||
|
endpoint := fmt.Sprintf("%s/api/v1/order/%s?auth=%s", t.baseURL, orderID, encodedAuth)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", endpoint, nil)
|
req, err := http.NewRequest("GET", endpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req.Header.Set("Authorization", t.authToken)
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
resp, err := t.client.Do(req)
|
resp, err := t.client.Do(req)
|
||||||
@@ -210,11 +214,15 @@ func (t *LighterTraderV2) GetActiveOrders(symbol string) ([]OrderResponse, error
|
|||||||
return nil, fmt.Errorf("failed to get market index: %w", err)
|
return nil, fmt.Errorf("failed to get market index: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build request URL
|
// URL encode auth token (contains colons that need encoding)
|
||||||
endpoint := fmt.Sprintf("%s/api/v1/accountActiveOrders?account_index=%d&market_id=%d",
|
// Authentication: Use "auth" query parameter (not Authorization header)
|
||||||
t.baseURL, t.accountIndex, marketIndex)
|
encodedAuth := url.QueryEscape(t.authToken)
|
||||||
|
|
||||||
logger.Debugf("📋 LIGHTER GetActiveOrders: endpoint=%s", endpoint)
|
// Build request URL with auth query parameter
|
||||||
|
endpoint := fmt.Sprintf("%s/api/v1/accountActiveOrders?account_index=%d&market_id=%d&auth=%s",
|
||||||
|
t.baseURL, t.accountIndex, marketIndex, encodedAuth)
|
||||||
|
|
||||||
|
logger.Debugf("📋 LIGHTER GetActiveOrders: endpoint=%s", endpoint[:min(len(endpoint), 120)]+"...")
|
||||||
|
|
||||||
// Send GET request
|
// Send GET request
|
||||||
req, err := http.NewRequest("GET", endpoint, nil)
|
req, err := http.NewRequest("GET", endpoint, nil)
|
||||||
@@ -222,8 +230,6 @@ func (t *LighterTraderV2) GetActiveOrders(symbol string) ([]OrderResponse, error
|
|||||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add authentication header
|
|
||||||
req.Header.Set("Authorization", t.authToken)
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
resp, err := t.client.Do(req)
|
resp, err := t.client.Do(req)
|
||||||
|
|||||||
Reference in New Issue
Block a user