From d02f51698c58da60a5e71fe9eb71e4f3eb605ccd Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Sat, 26 Aug 2023 07:53:06 +0000 Subject: [PATCH] Support bearer token for non-webdav requests --- .../java/org/aarboard/nextcloud/api/utils/ConnectorCommon.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/aarboard/nextcloud/api/utils/ConnectorCommon.java b/src/main/java/org/aarboard/nextcloud/api/utils/ConnectorCommon.java index 1a50850..d7378ce 100644 --- a/src/main/java/org/aarboard/nextcloud/api/utils/ConnectorCommon.java +++ b/src/main/java/org/aarboard/nextcloud/api/utils/ConnectorCommon.java @@ -154,6 +154,9 @@ private CompletableFuture executeRequest(final ResponseParser parser, // https://docs.nextcloud.com/server/14/developer_manual/core/ocs-share-api.html request.addHeader("OCS-APIRequest", "true"); request.addHeader("Content-Type", "application/x-www-form-urlencoded"); + if (serverConfig.getAuthenticationConfig().usesBearerTokenAuthentication()) { + request.addHeader("Authorization", "Bearer " + serverConfig.getAuthenticationConfig().getBearerToken()); + } request.setProtocolVersion(HttpVersion.HTTP_1_1); HttpClientContext context = prepareContext();