Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
address review comments on token refresh error handling and validation
Antonio Ojea5e1d8e7d6d4b
diff --git a/cmd/sam-node/oidc.go b/cmd/sam-node/oidc.goindex ef6c7b10..0de8216b 100644--- a/cmd/sam-node/oidc.go+++ b/cmd/sam-node/oidc.go@@ -380,8 +380,10 @@ func (n *SamNode) RefreshJWT(ctx context.Context, tokenURL, clientID, clientSecrError string `json:"error"`ErrorDescription string `json:"error_description"`}- _ = json.NewDecoder(resp.Body).Decode(&errResp)- return "", "", fmt.Errorf("refresh token request failed: %s - %s", errResp.Error, errResp.ErrorDescription)+ if err := json.NewDecoder(resp.Body).Decode(&errResp); err == nil && errResp.Error != "" {+ return "", "", fmt.Errorf("refresh token request failed (status %s): %s - %s", resp.Status, errResp.Error, errResp.ErrorDescription)+ }+ return "", "", fmt.Errorf("refresh token request failed with status: %s", resp.Status)}var tokenResp struct {@@ -397,5 +399,8 @@ func (n *SamNode) RefreshJWT(ctx context.Context, tokenURL, clientID, clientSecrif tokenResp.IdToken != "" {jwtStr = tokenResp.IdToken}+ if jwtStr == "" {+ return "", "", fmt.Errorf("token response did not contain an access_token or id_token")+ }return jwtStr, tokenResp.RefreshToken, nil}