This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 88834b644ca4 CAMEL-27575: camel-ibm-watsonx-data - send the token of 
oauthProfile as a Bearer token and renew it (#30870)
88834b644ca4 is described below

commit 88834b644ca4e10141e4bb05fd0d44f3d8af1077
Author: Federico Mariani <[email protected]>
AuthorDate: Thu Nov 26 17:16:09 2026 +0100

    CAMEL-27575: camel-ibm-watsonx-data - send the token of oauthProfile as a 
Bearer token and renew it (#30870)
    
    The endpoint obtained the access token of oauthProfile once at startup and
    used it as apiKey, so the IamAuthenticator of the IBM Cloud SDK posted it to
    IBM Cloud IAM as an API key, which IAM rejects, and the token was never
    renewed.
    
    With oauthProfile, the watsonx.data service now uses an 
OAuthProfileAuthenticator
    (an Authenticator of the IBM Cloud SDK core) that asks camel-oauth for the
    token of the profile on every request (camel-oauth caches it until it 
expires)
    and sends it as a Bearer token. The endpoint fails to start when the profile
    gives no token, and apiKey is no longer marked as required.
---
 .../camel/catalog/components/ibm-watsonx-data.json |   8 +-
 .../catalog/docs/ibm-watsonx-data-component.adoc   |  15 +-
 .../ibm/watsonx/data/ibm-watsonx-data.json         |   8 +-
 .../src/main/docs/ibm-watsonx-data-component.adoc  |  15 +-
 .../watsonx/data/OAuthProfileAuthenticator.java    |  87 +++++++++
 .../ibm/watsonx/data/WatsonxDataConfiguration.java |  12 +-
 .../ibm/watsonx/data/WatsonxDataEndpoint.java      |  45 +++--
 .../data/TestOAuthClientAuthenticationFactory.java |  70 +++++++
 .../ibm/watsonx/data/WatsonxDataOAuthTest.java     | 202 +++++++++++++++++++++
 .../camel/oauth-client-authentication-factory      |  17 ++
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    |   9 +
 .../dsl/IbmWatsonxDataComponentBuilderFactory.java |  10 +-
 .../dsl/WatsonxDataEndpointBuilderFactory.java     |  11 +-
 13 files changed, 461 insertions(+), 48 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watsonx-data.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watsonx-data.json
index 92b6f9c123f0..eb85a4db4688 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watsonx-data.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/ibm-watsonx-data.json
@@ -33,8 +33,8 @@
     "operation": { "index": 6, "kind": "property", "displayName": "Operation", 
"group": "producer", "label": "producer", "required": false, "type": "enum", 
"javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngin [...]
     "schemaName": { "index": 7, "kind": "property", "displayName": "Schema 
Name", "group": "producer", "label": "producer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "The schema name for 
schema and table operations" },
     "autowiredEnabled": { "index": 8, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "apiKey": { "index": 9, "kind": "property", "displayName": "Api Key", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication" },
-    "oauthProfile": { "index": 10, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
+    "apiKey": { "index": 9, "kind": "property", "displayName": "Api Key", 
"group": "security", "label": "security", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication, exchanged at IBM Cloud IAM for an access  [...]
+    "oauthProfile": { "index": 10, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
   },
   "headers": {
     "CamelIBMWatsonxDataOperation": { "index": 0, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngines", "getPrestis [...]
@@ -65,7 +65,7 @@
     "operation": { "index": 5, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngi [...]
     "schemaName": { "index": 6, "kind": "parameter", "displayName": "Schema 
Name", "group": "producer", "label": "producer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "The schema name for 
schema and table operations" },
     "lazyStartProducer": { "index": 7, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
-    "apiKey": { "index": 8, "kind": "parameter", "displayName": "Api Key", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication" },
-    "oauthProfile": { "index": 9, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
+    "apiKey": { "index": 8, "kind": "parameter", "displayName": "Api Key", 
"group": "security", "label": "security", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication, exchanged at IBM Cloud IAM for an access [...]
+    "oauthProfile": { "index": 9, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watsonx-data-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watsonx-data-component.adoc
index 00d3f65c8156..b7df2f9c00e1 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watsonx-data-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/ibm-watsonx-data-component.adoc
@@ -95,7 +95,12 @@ YAML::
 ----
 ====
 
-OAuth 2.0 Client Credentials grant is also supported when `camel-oauth` is on 
the classpath:
+OAuth 2.0 Client Credentials grant is also supported when `camel-oauth` is on 
the classpath: set `oauthProfile` in the
+place of `apiKey`. The access token of the profile is sent to watsonx.data as 
a `Bearer` token, and asked again for
+every request (`camel-oauth` caches it until it expires), so a long-running 
route keeps working; the endpoint fails to
+start when the profile gives no token. The identity provider must issue tokens 
that watsonx.data accepts: IBM Cloud
+IAM itself does not offer the Client Credentials grant, so with IBM Cloud use 
`apiKey`. The examples read the service
+URL of such a deployment from the `watsonx.data.service-url` property.
 
 [tabs]
 ====
@@ -104,7 +109,7 @@ Java::
 [source,java]
 ----
 from("direct:start")
-    
.to("ibm-watsonx-data:myLakehouse?oauthProfile=ibm&serviceUrl=https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2&operation=listCatalogs";);
+    
.to("ibm-watsonx-data:myLakehouse?oauthProfile=myidp&serviceUrl={{watsonx.data.service-url}}&operation=listCatalogs");
 ----
 
 XML::
@@ -113,7 +118,7 @@ XML::
 ----
 <route>
   <from uri="direct:start"/>
-  <to 
uri="ibm-watsonx-data:myLakehouse?oauthProfile=ibm&amp;serviceUrl=https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2&amp;operation=listCatalogs"/>
+  <to 
uri="ibm-watsonx-data:myLakehouse?oauthProfile=myidp&amp;serviceUrl={{watsonx.data.service-url}}&amp;operation=listCatalogs"/>
 </route>
 ----
 
@@ -128,8 +133,8 @@ YAML::
         - to:
             uri: ibm-watsonx-data:myLakehouse
             parameters:
-              oauthProfile: ibm
-              serviceUrl: 
"https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2";
+              oauthProfile: myidp
+              serviceUrl: "{{watsonx.data.service-url}}"
               operation: listCatalogs
 ----
 ====
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/generated/resources/META-INF/org/apache/camel/component/ibm/watsonx/data/ibm-watsonx-data.json
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/generated/resources/META-INF/org/apache/camel/component/ibm/watsonx/data/ibm-watsonx-data.json
index 92b6f9c123f0..eb85a4db4688 100644
--- 
a/components/camel-ibm/camel-ibm-watsonx-data/src/generated/resources/META-INF/org/apache/camel/component/ibm/watsonx/data/ibm-watsonx-data.json
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/generated/resources/META-INF/org/apache/camel/component/ibm/watsonx/data/ibm-watsonx-data.json
@@ -33,8 +33,8 @@
     "operation": { "index": 6, "kind": "property", "displayName": "Operation", 
"group": "producer", "label": "producer", "required": false, "type": "enum", 
"javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngin [...]
     "schemaName": { "index": 7, "kind": "property", "displayName": "Schema 
Name", "group": "producer", "label": "producer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "The schema name for 
schema and table operations" },
     "autowiredEnabled": { "index": 8, "kind": "property", "displayName": 
"Autowired Enabled", "group": "advanced", "label": "advanced", "required": 
false, "type": "boolean", "javaType": "boolean", "deprecated": false, 
"autowired": false, "secret": false, "defaultValue": true, "description": 
"Whether autowiring is enabled. This is used for automatic autowiring options 
(the option must be marked as autowired) by looking up in the registry to find 
if there is a single instance of matching t [...]
-    "apiKey": { "index": 9, "kind": "property", "displayName": "Api Key", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication" },
-    "oauthProfile": { "index": 10, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
+    "apiKey": { "index": 9, "kind": "property", "displayName": "Api Key", 
"group": "security", "label": "security", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication, exchanged at IBM Cloud IAM for an access  [...]
+    "oauthProfile": { "index": 10, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
   },
   "headers": {
     "CamelIBMWatsonxDataOperation": { "index": 0, "kind": "header", 
"displayName": "", "group": "producer", "label": "", "required": false, 
"javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngines", "getPrestis [...]
@@ -65,7 +65,7 @@
     "operation": { "index": 5, "kind": "parameter", "displayName": 
"Operation", "group": "producer", "label": "producer", "required": false, 
"type": "enum", "javaType": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataOperations", "enum": [ 
"listCatalogs", "getCatalog", "deleteCatalog", "listSchemas", "createSchema", 
"deleteSchema", "listTables", "getTable", "deleteTable", "updateTable", 
"registerTable", "getAllColumns", "listPrestoEngines", "getPrestoEngine", 
"listPrestissimoEngi [...]
     "schemaName": { "index": 6, "kind": "parameter", "displayName": "Schema 
Name", "group": "producer", "label": "producer", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "The schema name for 
schema and table operations" },
     "lazyStartProducer": { "index": 7, "kind": "parameter", "displayName": 
"Lazy Start Producer", "group": "producer (advanced)", "label": 
"producer,advanced", "required": false, "type": "boolean", "javaType": 
"boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the producer should be started 
lazy (on the first message). By starting lazy you can use this to allow 
CamelContext and routes to startup in situations where a produc [...]
-    "apiKey": { "index": 8, "kind": "parameter", "displayName": "Api Key", 
"group": "security", "label": "security", "required": true, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication" },
-    "oauthProfile": { "index": 9, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
+    "apiKey": { "index": 8, "kind": "parameter", "displayName": "Api Key", 
"group": "security", "label": "security", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": true, "security": "secret", "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "IBM Cloud API key for 
authentication, exchanged at IBM Cloud IAM for an access [...]
+    "oauthProfile": { "index": 9, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.ibm.watsonx.data.WatsonxDataConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials g [...]
   }
 }
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/docs/ibm-watsonx-data-component.adoc
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/docs/ibm-watsonx-data-component.adoc
index 00d3f65c8156..b7df2f9c00e1 100644
--- 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/docs/ibm-watsonx-data-component.adoc
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/docs/ibm-watsonx-data-component.adoc
@@ -95,7 +95,12 @@ YAML::
 ----
 ====
 
-OAuth 2.0 Client Credentials grant is also supported when `camel-oauth` is on 
the classpath:
+OAuth 2.0 Client Credentials grant is also supported when `camel-oauth` is on 
the classpath: set `oauthProfile` in the
+place of `apiKey`. The access token of the profile is sent to watsonx.data as 
a `Bearer` token, and asked again for
+every request (`camel-oauth` caches it until it expires), so a long-running 
route keeps working; the endpoint fails to
+start when the profile gives no token. The identity provider must issue tokens 
that watsonx.data accepts: IBM Cloud
+IAM itself does not offer the Client Credentials grant, so with IBM Cloud use 
`apiKey`. The examples read the service
+URL of such a deployment from the `watsonx.data.service-url` property.
 
 [tabs]
 ====
@@ -104,7 +109,7 @@ Java::
 [source,java]
 ----
 from("direct:start")
-    
.to("ibm-watsonx-data:myLakehouse?oauthProfile=ibm&serviceUrl=https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2&operation=listCatalogs";);
+    
.to("ibm-watsonx-data:myLakehouse?oauthProfile=myidp&serviceUrl={{watsonx.data.service-url}}&operation=listCatalogs");
 ----
 
 XML::
@@ -113,7 +118,7 @@ XML::
 ----
 <route>
   <from uri="direct:start"/>
-  <to 
uri="ibm-watsonx-data:myLakehouse?oauthProfile=ibm&amp;serviceUrl=https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2&amp;operation=listCatalogs"/>
+  <to 
uri="ibm-watsonx-data:myLakehouse?oauthProfile=myidp&amp;serviceUrl={{watsonx.data.service-url}}&amp;operation=listCatalogs"/>
 </route>
 ----
 
@@ -128,8 +133,8 @@ YAML::
         - to:
             uri: ibm-watsonx-data:myLakehouse
             parameters:
-              oauthProfile: ibm
-              serviceUrl: 
"https://us-south.lakehouse.cloud.ibm.com/lakehouse/api/v2";
+              oauthProfile: myidp
+              serviceUrl: "{{watsonx.data.service-url}}"
               operation: listCatalogs
 ----
 ====
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/OAuthProfileAuthenticator.java
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/OAuthProfileAuthenticator.java
new file mode 100644
index 000000000000..7f0a8bcbcf79
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/OAuthProfileAuthenticator.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.watsonx.data;
+
+import com.ibm.cloud.sdk.core.security.Authenticator;
+import okhttp3.Request;
+import org.apache.camel.CamelContext;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.OAuthClientAuthenticationFactory;
+import org.apache.camel.support.ResolverHelper;
+
+/**
+ * An authenticator of the IBM Cloud SDK that sends the access token of a 
Camel OAuth profile as a {@code Bearer} token.
+ * <p>
+ * The token is asked from the OAuth client factory (camel-oauth) for every 
request, so it is renewed when it expires:
+ * the factory caches it until then (see {@code 
camel.oauth.<profile>.cache-tokens}). The token is never exchanged at
+ * IBM Cloud IAM, as an IBM Cloud API key would be.
+ */
+public final class OAuthProfileAuthenticator implements Authenticator {
+
+    private static final String AUTHORIZATION = "Authorization";
+
+    private final CamelContext camelContext;
+    private final String profileName;
+    private final OAuthClientAuthenticationFactory factory;
+
+    public OAuthProfileAuthenticator(CamelContext camelContext, String 
profileName) {
+        this.camelContext = camelContext;
+        this.profileName = profileName;
+        this.factory = ResolverHelper.resolveMandatoryBootstrapService(
+                camelContext, OAuthClientAuthenticationFactory.FACTORY, 
OAuthClientAuthenticationFactory.class,
+                "camel-oauth");
+    }
+
+    /**
+     * The access token of the profile.
+     *
+     * @throws IllegalStateException when the profile gives no token
+     */
+    public String token() {
+        String token;
+        try {
+            token = factory.resolveToken(camelContext, profileName);
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new RuntimeCamelException("Cannot obtain an access token for 
the OAuth profile " + profileName, e);
+        }
+        if (token == null || token.isBlank()) {
+            throw new IllegalStateException("The OAuth profile " + profileName 
+ " gave no access token");
+        }
+        return token;
+    }
+
+    @Override
+    public void validate() {
+        // the endpoint asks for a token when it starts
+    }
+
+    @Override
+    public String authenticationType() {
+        return Authenticator.AUTHTYPE_BEARER_TOKEN;
+    }
+
+    @Override
+    public void authenticate(Request.Builder requestBuilder) {
+        requestBuilder.header(AUTHORIZATION, "Bearer " + token());
+    }
+
+    public String getProfileName() {
+        return profileName;
+    }
+}
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataConfiguration.java
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataConfiguration.java
index 45896d23e0c7..bb8762c430f7 100644
--- 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataConfiguration.java
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataConfiguration.java
@@ -28,14 +28,16 @@ import org.apache.camel.spi.UriParams;
 public class WatsonxDataConfiguration implements Cloneable {
 
     // Authentication
-    @UriParam(label = "security", security = "secret", description = "IBM 
Cloud API key for authentication")
-    @Metadata(required = true)
+    @UriParam(label = "security", security = "secret",
+              description = "IBM Cloud API key for authentication, exchanged 
at IBM Cloud IAM for an access token. Required"
+                            + " unless oauthProfile is set.")
     private String apiKey;
 
     @UriParam(label = "security",
-              description = "OAuth profile name for obtaining an access token 
via the OAuth 2.0 Client Credentials grant. "
-                            + "When set, the token is acquired from the 
configured identity provider and used as apiKey. "
-                            + "Requires camel-oauth on the classpath.")
+              description = "OAuth profile name for obtaining an access token 
via the OAuth 2.0 Client Credentials grant."
+                            + " When set, the token of the configured identity 
provider is sent to watsonx.data as a Bearer"
+                            + " token instead of an IBM Cloud API key, and 
obtained again when it expires. Requires"
+                            + " camel-oauth on the classpath.")
     private String oauthProfile;
 
     // Connection
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataEndpoint.java
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataEndpoint.java
index dd0e2176cb95..6a15537b9064 100644
--- 
a/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataEndpoint.java
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/main/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataEndpoint.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.ibm.watsonx.data;
 
+import com.ibm.cloud.sdk.core.security.Authenticator;
 import com.ibm.cloud.sdk.core.security.IamAuthenticator;
 import com.ibm.cloud.watsonxdata.watsonx_data.v3.WatsonxData;
 import org.apache.camel.Category;
@@ -31,7 +32,6 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 import org.apache.camel.support.DefaultEndpoint;
-import org.apache.camel.support.OAuthHelper;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -74,6 +74,8 @@ public class WatsonxDataEndpoint extends DefaultEndpoint 
implements EndpointServ
     private WatsonxDataConfiguration configuration;
 
     private WatsonxData watsonxDataService;
+    // the Bearer token authenticator of the oauthProfile, created when the 
endpoint starts
+    private OAuthProfileAuthenticator oauthAuthenticator;
 
     public WatsonxDataEndpoint(String uri, WatsonxDataComponent component, 
WatsonxDataConfiguration configuration) {
         super(uri, component);
@@ -93,26 +95,30 @@ public class WatsonxDataEndpoint extends DefaultEndpoint 
implements EndpointServ
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-        resolveOAuthToken();
         validateConfiguration();
-    }
-
-    private void resolveOAuthToken() throws Exception {
-        if (ObjectHelper.isEmpty(configuration.getOauthProfile())) {
-            return;
+        if (ObjectHelper.isNotEmpty(configuration.getOauthProfile())) {
+            OAuthProfileAuthenticator authenticator
+                    = new OAuthProfileAuthenticator(getCamelContext(), 
configuration.getOauthProfile());
+            // fail at startup rather than at the first exchange when the 
OAuth profile cannot give a token
+            authenticator.token();
+            synchronized (this) {
+                oauthAuthenticator = authenticator;
+                // a client created before startup is created again with this 
authenticator
+                watsonxDataService = null;
+            }
         }
-        
configuration.setApiKey(OAuthHelper.resolveOAuthToken(getCamelContext(), 
configuration.getOauthProfile()));
     }
 
     @Override
-    protected void doStop() throws Exception {
+    protected synchronized void doStop() throws Exception {
         super.doStop();
         watsonxDataService = null;
+        oauthAuthenticator = null;
     }
 
     private void validateConfiguration() {
-        if (configuration.getApiKey() == null || 
configuration.getApiKey().isEmpty()) {
-            throw new IllegalArgumentException("API key is required");
+        if (ObjectHelper.isEmpty(configuration.getApiKey()) && 
ObjectHelper.isEmpty(configuration.getOauthProfile())) {
+            throw new IllegalArgumentException("API key is required (or set 
oauthProfile)");
         }
         if (configuration.getServiceUrl() == null || 
configuration.getServiceUrl().isEmpty()) {
             throw new IllegalArgumentException("Service URL is required");
@@ -120,13 +126,20 @@ public class WatsonxDataEndpoint extends DefaultEndpoint 
implements EndpointServ
     }
 
     /**
-     * Gets or creates the WatsonxData service instance.
+     * Gets or creates the WatsonxData service instance: it authenticates with 
the Bearer token of the OAuth profile
+     * when {@code oauthProfile} is set, else with an IBM Cloud IAM token for 
the {@code apiKey}.
      */
-    public WatsonxData getWatsonxDataService() {
+    public synchronized WatsonxData getWatsonxDataService() {
         if (watsonxDataService == null) {
-            IamAuthenticator authenticator = new IamAuthenticator.Builder()
-                    .apikey(configuration.getApiKey())
-                    .build();
+            Authenticator authenticator;
+            if (ObjectHelper.isNotEmpty(configuration.getOauthProfile())) {
+                if (oauthAuthenticator == null) {
+                    oauthAuthenticator = new 
OAuthProfileAuthenticator(getCamelContext(), configuration.getOauthProfile());
+                }
+                authenticator = oauthAuthenticator;
+            } else {
+                authenticator = new 
IamAuthenticator.Builder().apikey(configuration.getApiKey()).build();
+            }
             watsonxDataService = new WatsonxData("watsonxdata", authenticator);
             watsonxDataService.setServiceUrl(configuration.getServiceUrl());
         }
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/TestOAuthClientAuthenticationFactory.java
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/TestOAuthClientAuthenticationFactory.java
new file mode 100644
index 000000000000..f1342cfd0feb
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/TestOAuthClientAuthenticationFactory.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.watsonx.data;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.Function;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.OAuthClientAuthenticationFactory;
+import org.apache.camel.spi.OAuthClientConfig;
+
+/**
+ * The OAuth client factory of the tests, in the place of camel-oauth (see
+ * META-INF/services/org/apache/camel/oauth-client-authentication-factory): a 
test decides which token a profile gives.
+ */
+public class TestOAuthClientAuthenticationFactory implements 
OAuthClientAuthenticationFactory {
+
+    private static final Function<String, String> NO_TOKEN = profile -> {
+        throw new IllegalStateException("No OAuth token for the profile " + 
profile);
+    };
+
+    static volatile Function<String, String> tokens = NO_TOKEN;
+    static final List<String> PROFILES = new CopyOnWriteArrayList<>();
+
+    /**
+     * Sets the tokens the profiles give.
+     */
+    public static void tokens(Function<String, String> tokens) {
+        TestOAuthClientAuthenticationFactory.tokens = tokens;
+    }
+
+    /**
+     * No profile gives a token.
+     */
+    public static void reset() {
+        tokens = NO_TOKEN;
+        PROFILES.clear();
+    }
+
+    @Override
+    public String resolveToken(OAuthClientConfig config) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String resolveToken(CamelContext context, String profileName) {
+        PROFILES.add(profileName);
+        return tokens.apply(profileName);
+    }
+
+    @Override
+    public String resolveToken(CamelContext context) {
+        throw new UnsupportedOperationException();
+    }
+}
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataOAuthTest.java
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataOAuthTest.java
new file mode 100644
index 000000000000..3af10aab1273
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/java/org/apache/camel/component/ibm/watsonx/data/WatsonxDataOAuthTest.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.ibm.watsonx.data;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.ibm.cloud.watsonxdata.watsonx_data.v3.model.ColumnsCollection;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpServer;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * The oauthProfile option: the access token of the profile is sent to 
watsonx.data as a Bearer token, asked again for
+ * every request so a renewed token is used, and never posted to IBM Cloud IAM 
as an API key. A JDK HttpServer plays
+ * watsonx.data and IAM.
+ */
+class WatsonxDataOAuthTest extends CamelTestSupport {
+
+    private static final AtomicInteger TOKEN = new AtomicInteger();
+    private static final AtomicInteger IAM_REQUESTS = new AtomicInteger();
+    private static final List<String> AUTHORIZATIONS = new 
CopyOnWriteArrayList<>();
+
+    private static HttpServer server;
+
+    @BeforeAll
+    static void startServer() throws IOException {
+        server = HttpServer.create(new InetSocketAddress("localhost", 0), 0);
+        server.createContext("/identity/token", exchange -> {
+            IAM_REQUESTS.incrementAndGet();
+            exchange.getRequestBody().readAllBytes();
+            respond(exchange, 400, 
"{\"errorCode\":\"BXNIM0415E\",\"errorMessage\":\"Provided API key could not be 
found.\"}");
+        });
+        server.createContext("/columns", exchange -> {
+            
AUTHORIZATIONS.add(exchange.getRequestHeaders().getFirst("Authorization"));
+            respond(exchange, 200, "{\"columns\":[],\"count\":0}");
+        });
+        server.start();
+        // the route starts before each test, and asks the token of its 
profile at startup
+        
TestOAuthClientAuthenticationFactory.tokens(WatsonxDataOAuthTest::token);
+    }
+
+    private static String token(String profile) {
+        return "access-token-" + profile + "-" + TOKEN.get();
+    }
+
+    @AfterAll
+    static void stopServer() {
+        server.stop(0);
+        TestOAuthClientAuthenticationFactory.reset();
+    }
+
+    @BeforeEach
+    void reset() {
+        TOKEN.set(1);
+        IAM_REQUESTS.set(0);
+        AUTHORIZATIONS.clear();
+        TestOAuthClientAuthenticationFactory.PROFILES.clear();
+    }
+
+    private static void respond(HttpExchange exchange, int status, String 
body) throws IOException {
+        byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
+        exchange.getResponseHeaders().add("Content-Type", "application/json");
+        exchange.sendResponseHeaders(status, bytes.length);
+        try (OutputStream out = exchange.getResponseBody()) {
+            out.write(bytes);
+        }
+    }
+
+    private static String uri(String profile) {
+        return "ibm-watsonx-data:test?oauthProfile=" + profile + 
"&catalogName=iceberg_data&schemaName=sales"
+               + 
"&engineId=presto-01&operation=getAllColumns&serviceUrl=http://localhost:"; + 
server.getAddress().getPort();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:start").to(uri("myidp"));
+            }
+        };
+    }
+
+    @Test
+    void tokenIsSentAsBearerTokenAndRenewed() {
+        // the token is never exchanged at IBM Cloud IAM as an API key: the 
client has no IAM authenticator
+        WatsonxDataEndpoint endpoint = context.getEndpoint(uri("myidp"), 
WatsonxDataEndpoint.class);
+        assertInstanceOf(OAuthProfileAuthenticator.class, 
endpoint.getWatsonxDataService().getAuthenticator());
+
+        Exchange first = template.send("direct:start", e -> 
e.getIn().setBody(null));
+        assertNull(first.getException());
+        assertInstanceOf(ColumnsCollection.class, 
first.getMessage().getBody());
+        // the token is asked for this request, not reused from the startup
+        assertEquals(List.of("myidp"), 
TestOAuthClientAuthenticationFactory.PROFILES);
+        // the identity provider renews the token: the next request must use 
the new one
+        TOKEN.set(2);
+        Exchange second = template.send("direct:start", e -> 
e.getIn().setBody(null));
+        assertNull(second.getException());
+        assertEquals(List.of("myidp", "myidp"), 
TestOAuthClientAuthenticationFactory.PROFILES);
+
+        assertEquals(List.of("Bearer access-token-myidp-1", "Bearer 
access-token-myidp-2"), AUTHORIZATIONS);
+        assertEquals(0, IAM_REQUESTS.get());
+    }
+
+    @Test
+    void clientCreatedBeforeStartupUsesTheProfile() throws Exception {
+        WatsonxDataConfiguration configuration = new 
WatsonxDataConfiguration();
+        configuration.setApiKey("an-api-key");
+        configuration.setOauthProfile("both");
+        configuration.setServiceUrl("http://localhost:"; + 
server.getAddress().getPort());
+        WatsonxDataEndpoint endpoint = new WatsonxDataEndpoint(
+                "ibm-watsonx-data:both", 
context.getComponent("ibm-watsonx-data", WatsonxDataComponent.class),
+                configuration);
+        endpoint.setCamelContext(context);
+        // the profile takes the place of the API key, also for a client 
obtained before the endpoint starts
+        assertInstanceOf(OAuthProfileAuthenticator.class, 
endpoint.getWatsonxDataService().getAuthenticator());
+        endpoint.start();
+        try {
+            assertInstanceOf(OAuthProfileAuthenticator.class, 
endpoint.getWatsonxDataService().getAuthenticator());
+        } finally {
+            endpoint.stop();
+        }
+    }
+
+    @Test
+    void profileWithNullTokenFailsAtStartup() {
+        TestOAuthClientAuthenticationFactory.tokens(profile -> null);
+        try {
+            Exception e = assertThrows(Exception.class, () -> 
context.getEndpoint(uri("nothing")));
+            assertInstanceOf(IllegalStateException.class, e.getCause());
+            assertEquals("The OAuth profile nothing gave no access token", 
e.getCause().getMessage());
+        } finally {
+            
TestOAuthClientAuthenticationFactory.tokens(WatsonxDataOAuthTest::token);
+        }
+    }
+
+    @Test
+    void profileWithoutTokenFailsAtStartup() {
+        TestOAuthClientAuthenticationFactory.tokens(profile -> {
+            throw new IllegalStateException("unknown profile " + profile);
+        });
+        try {
+            // the endpoint starts when it is resolved
+            Exception e = assertThrows(Exception.class, () -> 
context.getEndpoint(uri("missing")));
+            assertInstanceOf(IllegalStateException.class, e.getCause());
+            assertEquals("unknown profile missing", e.getCause().getMessage());
+        } finally {
+            
TestOAuthClientAuthenticationFactory.tokens(WatsonxDataOAuthTest::token);
+        }
+    }
+
+    @Test
+    void profileWithEmptyTokenFailsAtStartup() {
+        TestOAuthClientAuthenticationFactory.tokens(profile -> "");
+        try {
+            Exception e = assertThrows(Exception.class, () -> 
context.getEndpoint(uri("empty")));
+            assertInstanceOf(IllegalStateException.class, e.getCause());
+            assertEquals("The OAuth profile empty gave no access token", 
e.getCause().getMessage());
+        } finally {
+            
TestOAuthClientAuthenticationFactory.tokens(WatsonxDataOAuthTest::token);
+        }
+    }
+
+    @Test
+    void endpointWithoutApiKeyOrProfileFailsAtStartup() {
+        Exception e = assertThrows(Exception.class, () -> context.getEndpoint(
+                
"ibm-watsonx-data:none?operation=getAllColumns&serviceUrl=http://localhost:";
+                                                                              
+ server.getAddress().getPort()));
+        assertInstanceOf(IllegalArgumentException.class, e.getCause());
+    }
+}
diff --git 
a/components/camel-ibm/camel-ibm-watsonx-data/src/test/resources/META-INF/services/org/apache/camel/oauth-client-authentication-factory
 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/resources/META-INF/services/org/apache/camel/oauth-client-authentication-factory
new file mode 100644
index 000000000000..0b3f6d78e404
--- /dev/null
+++ 
b/components/camel-ibm/camel-ibm-watsonx-data/src/test/resources/META-INF/services/org/apache/camel/oauth-client-authentication-factory
@@ -0,0 +1,17 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+class=org.apache.camel.component.ibm.watsonx.data.TestOAuthClientAuthenticationFactory
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 6195e29cb3ce..e415a0f8c3f9 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -814,6 +814,15 @@ A URL whose path is not the endpoint of the server, such 
as `http://host:8080/v1
 because its path was ignored, and now fails: set the URL of the endpoint, here 
`http://host:8080/mcp`, or remove the
 path. The URL must be absolute, with a scheme and a host.
 
+=== camel-ibm-watsonx-data - the OAuth token of oauthProfile is sent as a 
Bearer token
+
+With `oauthProfile`, the endpoint used to obtain an access token once at 
startup and use it as `apiKey`, so the token
+was posted to IBM Cloud IAM as if it were an IBM Cloud API key, which IAM 
rejects. The token is now sent to
+watsonx.data as a `Bearer` token, and asked from `camel-oauth` again for every 
request, so it is renewed when it
+expires; the endpoint fails to start when the profile gives no token. The 
identity provider must therefore issue tokens
+that watsonx.data accepts. `apiKey` is no longer marked as required in the 
catalog, as `oauthProfile` can take its
+place; an endpoint with neither still fails to start.
+
 === camel-micrometer, camel-opentelemetry-metrics - tags and attributes from 
headers are used as given
 
 The `micrometer` and `opentelemetry-metrics` producers now use the tags of the 
`CamelMetricsTags` header and the
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonxDataComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonxDataComponentBuilderFactory.java
index b8f666eef18d..66745a9469d2 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonxDataComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/IbmWatsonxDataComponentBuilderFactory.java
@@ -208,7 +208,8 @@ public interface IbmWatsonxDataComponentBuilderFactory {
         }
     
         /**
-         * IBM Cloud API key for authentication.
+         * IBM Cloud API key for authentication, exchanged at IBM Cloud IAM for
+         * an access token. Required unless oauthProfile is set.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
@@ -224,9 +225,10 @@ public interface IbmWatsonxDataComponentBuilderFactory {
     
         /**
          * OAuth profile name for obtaining an access token via the OAuth 2.0
-         * Client Credentials grant. When set, the token is acquired from the
-         * configured identity provider and used as apiKey. Requires 
camel-oauth
-         * on the classpath.
+         * Client Credentials grant. When set, the token of the configured
+         * identity provider is sent to watsonx.data as a Bearer token instead
+         * of an IBM Cloud API key, and obtained again when it expires. 
Requires
+         * camel-oauth on the classpath.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonxDataEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonxDataEndpointBuilderFactory.java
index dbf51a023a36..7d21b4c472be 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonxDataEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/WatsonxDataEndpointBuilderFactory.java
@@ -148,11 +148,11 @@ public interface WatsonxDataEndpointBuilderFactory {
             return this;
         }
         /**
-         * IBM Cloud API key for authentication.
+         * IBM Cloud API key for authentication, exchanged at IBM Cloud IAM for
+         * an access token. Required unless oauthProfile is set.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
-         * Required: true
          * Group: security
          * 
          * @param apiKey the value to set
@@ -164,9 +164,10 @@ public interface WatsonxDataEndpointBuilderFactory {
         }
         /**
          * OAuth profile name for obtaining an access token via the OAuth 2.0
-         * Client Credentials grant. When set, the token is acquired from the
-         * configured identity provider and used as apiKey. Requires 
camel-oauth
-         * on the classpath.
+         * Client Credentials grant. When set, the token of the configured
+         * identity provider is sent to watsonx.data as a Bearer token instead
+         * of an IBM Cloud API key, and obtained again when it expires. 
Requires
+         * camel-oauth on the classpath.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 

Reply via email to