diff --git a/README.md b/README.md index a3278a88..908d4b34 100644 --- a/README.md +++ b/README.md @@ -48,11 +48,11 @@ The original work is also licensed under the Apache 2 License. Here's a command-line guide to uploading some payload: ``` -export BASIC_AUTH='the-token' +export AUTH='the-token' export HOST='the-host' curl -F "file=@foo.json.gz;type=application/vnd.redhat.runtimes-java-general.analytics+tgz" \ - -H "Authorization: Basic ${BASIC_AUTH}" \ + -H "Authorization: Bearer ${AUTH}" \ "https://${HOST}/api/ingress/v1/upload" -v --insecure ``` @@ -62,7 +62,7 @@ Or if you prefer HTTPie: http --verbose --multipart $HOST/api/ingress/v1/upload \ 'file@foo.json.gz;type=application/vnd.redhat.runtimes-java-general.analytics+tgz' \ type='application/vnd.redhat.runtimes-java-general.analytics+tgz' \ -"Authorization":"Basic ${BASIC_AUTH}" +"Authorization":"Bearer ${AUTH}" ``` ## Environment variables and system properties diff --git a/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java b/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java index e7248204..28e86f57 100644 --- a/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java +++ b/runtime/src/main/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClient.java @@ -1,4 +1,4 @@ -/* Copyright (C) Red Hat 2023 */ +/* Copyright (C) Red Hat 2023-2024 */ package com.redhat.insights.core.httpclient; import static com.redhat.insights.InsightsErrorCode.*; @@ -126,7 +126,7 @@ protected void sendInsightsReportWithClient( if (!configuration.useMTLS()) { final var authToken = configuration.getMaybeAuthToken().get(); - requestBuilder = requestBuilder.setHeader("Authorization", "Basic " + authToken); + requestBuilder = requestBuilder.setHeader("Authorization", "Bearer " + authToken); } requestBuilder = requestBuilder.uri( diff --git a/runtime/src/test/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClientTest.java b/runtime/src/test/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClientTest.java index 1b7d5136..a2f7a080 100644 --- a/runtime/src/test/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClientTest.java +++ b/runtime/src/test/java/com/redhat/insights/core/httpclient/InsightsJdkHttpClientTest.java @@ -1,4 +1,4 @@ -/* Copyright (C) Red Hat 2023 */ +/* Copyright (C) Red Hat 2023-2024 */ package com.redhat.insights.core.httpclient; import static org.junit.jupiter.api.Assertions.*; @@ -207,7 +207,7 @@ public void testSendReportWithoutMtls() throws IOException, InterruptedException // if using token, there should be authorization header assertEquals(1, request.get().headers().allValues("Authorization").size()); - assertEquals("Basic randomToken", request.get().headers().allValues("Authorization").get(0)); + assertEquals("Bearer randomToken", request.get().headers().allValues("Authorization").get(0)); } @Test