You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/03/01 06:01:48 UTC

(camel) branch main updated: CAMEL-20498 Fix HTTP OAuth2 Authorization header (#13356)

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 ce48ed8d2b7 CAMEL-20498 Fix HTTP OAuth2 Authorization header (#13356)
ce48ed8d2b7 is described below

commit ce48ed8d2b7e529723d1dcfcfaab9e678dbda285
Author: Joshua Grisham <10...@users.noreply.github.com>
AuthorDate: Fri Mar 1 07:01:42 2024 +0100

    CAMEL-20498 Fix HTTP OAuth2 Authorization header (#13356)
---
 .../java/org/apache/camel/component/http/OAuth2ClientConfigurer.java    | 2 +-
 .../org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/OAuth2ClientConfigurer.java b/components/camel-http/src/main/java/org/apache/camel/component/http/OAuth2ClientConfigurer.java
index ab4005cfd68..cceba3c2130 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/OAuth2ClientConfigurer.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/OAuth2ClientConfigurer.java
@@ -61,7 +61,7 @@ public class OAuth2ClientConfigurer implements HttpClientConfigurer {
 
                     if (response.getCode() == 200) {
                         String accessToken = ((JsonObject) Jsoner.deserialize(responseString)).getString("access_token");
-                        request.addHeader(HttpHeaders.AUTHORIZATION, accessToken);
+                        request.addHeader(HttpHeaders.AUTHORIZATION, "Bearer " + accessToken);
                     } else {
                         throw new HttpException(
                                 "Received error response from token request with Status Code: " + response.getCode());
diff --git a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java
index 39090de00a3..4520ed43e33 100644
--- a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java
+++ b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpOAuth2AuthenticationTest.java
@@ -42,7 +42,7 @@ public class HttpOAuth2AuthenticationTest extends BaseHttpTest {
     @Override
     public void setUp() throws Exception {
         Map<String, String> expectedHeaders = new HashMap<>();
-        expectedHeaders.put("Authorization", FAKE_TOKEN);
+        expectedHeaders.put("Authorization", "Bearer " + FAKE_TOKEN);
 
         localServer = ServerBootstrap.bootstrap().setHttpProcessor(getBasicHttpProcessor())
                 .setConnectionReuseStrategy(getConnectionReuseStrategy()).setResponseFactory(getHttpResponseFactory())