Skip to content

Commit 67e2767

Browse files
committed
fix streaming endpoint bug
1 parent fc1612e commit 67e2767

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

.vscode/launch.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8-
"type": "lldb",
9-
"request": "launch",
108
"name": "Debug",
11-
"program": "${workspaceFolder}/<executable file>",
12-
"args": [],
9+
"type": "go",
10+
"request": "launch",
11+
"mode": "auto",
12+
"program": "${workspaceFolder}",
13+
"args": ["auth", "oauth2"],
1314
"cwd": "${workspaceFolder}"
1415
}
1516
]

api/endpoints.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ func IsStreamingEndpoint(endpoint string) bool {
2626
}
2727
}
2828

29+
// Remove query parameters if present
30+
if queryIndex := strings.Index(path, "?"); queryIndex != -1 {
31+
path = path[:queryIndex]
32+
}
33+
2934
normalizedEndpoint := strings.TrimSuffix(path, "/")
3035

3136
return StreamingEndpoints[normalizedEndpoint]

auth/auth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,20 +312,20 @@ func (a *Auth) fetchUsername(accessToken string) (string, error) {
312312
return "", xurlErrors.NewAuthError("IOError", err)
313313
}
314314

315-
var data map[string]interface{}
315+
var data map[string]any
316316
if err := json.Unmarshal(body, &data); err != nil {
317317
return "", xurlErrors.NewAuthError("JSONDeserializationError", err)
318318
}
319319

320320
if data["data"] != nil {
321-
if userData, ok := data["data"].(map[string]interface{}); ok {
321+
if userData, ok := data["data"].(map[string]any); ok {
322322
if username, ok := userData["username"].(string); ok {
323323
return username, nil
324324
}
325325
}
326326
}
327327

328-
return "", xurlErrors.NewAuthError("UsernameNotFound", errors.New("username not found in response"))
328+
return "", xurlErrors.NewAuthError("UsernameNotFound", errors.New("username not found when fetching username"))
329329
}
330330

331331
func generateSignature(method, urlStr string, params map[string]string, consumerSecret, tokenSecret string) (string, error) {

0 commit comments

Comments
 (0)