Compare commits

...

1 Commits

Author SHA1 Message Date
hy001
b2f814f984 fix console auth headers for go java client 2026-04-29 18:19:50 +08:00

View File

@ -326,8 +326,7 @@ func (c *Client) AuthenticateConsoleToken(ctx context.Context, authorization str
}
endpoint := strings.TrimRight(c.cfg.Java.ConsoleBaseURL, "/") + "/account/info"
headers := http.Header{}
headers.Set("Authorization", authorization)
headers := javaConsoleHeaders(authorization)
var resp resultResponse[ConsoleAccount]
if err := c.getJSON(ctx, endpoint, headers, &resp); err != nil {
@ -339,6 +338,18 @@ func (c *Client) AuthenticateConsoleToken(ctx context.Context, authorization str
return resp.Body, nil
}
func javaConsoleHeaders(authorization string) http.Header {
headers := http.Header{}
headers.Set("Authorization", strings.TrimSpace(authorization))
headers.Set("Req-Sys-Origin", "origin=ops;originChild=ops;")
headers.Set("Req-Client", "Ops")
headers.Set("Req-App-Intel", "version=1.0.0;build=1;channel=ops;")
headers.Set("Req-Version", "v2")
headers.Set("Req-Lang", "zh-CN")
headers.Set("Req-Zone", "Asia/Shanghai")
return headers
}
func parseUserCredentialToken(token string) (UserCredential, error) {
token = strings.TrimSpace(token)
if token == "" {