Claus Ibsen created CAMEL-26162:
-----------------------------------

             Summary: camel-workday - the token request sends the Basic header 
as Arrays.toString of the bytes, so getting an access token fails
                 Key: CAMEL-26162
                 URL: https://issues.apache.org/jira/browse/CAMEL-26162
             Project: Camel
          Issue Type: Bug
          Components: camel-workday
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of workday (CAMEL-24961, PR #28410).

h4. 1. The token request sends a malformed Authorization header

{{AuthClientForIntegration.createPostMethod}} (main 2a465aa4814c, line 98) 
builds the header with {{"Basic " + 
Arrays.toString(Base64.getEncoder().encode(...))}}. {{Arrays.toString(byte[])}} 
gives the list of byte values, so the header is {{Basic [89, 50, 108, ...]}} 
instead of the Base64 text, and the refresh-token request is rejected by 
Workday: no call can get an access token. Checked on 4.24.0-SNAPSHOT with a 
local HTTPS server as the token endpoint, which received {{Basic [89, 50, 108, 
...]}}.

Proposed: use {{Base64.getEncoder().encodeToString((clientId + ":" + 
clientSecret).getBytes(StandardCharsets.UTF_8))}}.

h4. 2. The access token is cut from the response by fixed offsets

{{AuthClientForIntegration.parseResponse}} (main 2a465aa4814c, line 114) takes 
{{response.substring(response.indexOf("access_token") + 16, response.length() - 
3)}}. This only works when the JSON has exactly that spacing and 
{{access_token}} is the last field; with other whitespace or other fields after 
it (e.g. {{token_type}}, {{expires_in}}) the token is wrong. Checked on 
4.24.0-SNAPSHOT with the local HTTPS fake.

Proposed: parse the response as JSON (Jackson is already on the classpath) and 
read the {{access_token}} field.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to