diff --git a/lib/KOReaderSync/KOReaderSyncClient.cpp b/lib/KOReaderSync/KOReaderSyncClient.cpp index e0bc410d..1e4f512d 100644 --- a/lib/KOReaderSync/KOReaderSyncClient.cpp +++ b/lib/KOReaderSync/KOReaderSyncClient.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -75,6 +74,11 @@ esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, config.buffer_size_tx = HTTP_BUF_SIZE; config.crt_bundle_attach = esp_crt_bundle_attach; + // HTTP Basic Auth for Calibre-Web-Automated compatibility + config.username = KOREADER_STORE.getUsername().c_str(); + config.password = KOREADER_STORE.getPassword().c_str(); + config.auth_type = HTTP_AUTH_TYPE_BASIC; + esp_http_client_handle_t client = esp_http_client_init(&config); if (!client) return nullptr; @@ -87,16 +91,6 @@ esp_http_client_handle_t createClient(const char* url, ResponseBuffer* buf, return nullptr; } - // HTTP Basic Auth for Calibre-Web-Automated compatibility - std::string credentials = KOREADER_STORE.getUsername() + ":" + KOREADER_STORE.getPassword(); - String encoded = base64::encode(reinterpret_cast(credentials.data()), credentials.size()); - std::string authHeader = "Basic " + std::string(encoded.c_str()); - if (esp_http_client_set_header(client, "Authorization", authHeader.c_str()) != ESP_OK) { - LOG_ERR("KOSync", "Failed to set Authorization header"); - esp_http_client_cleanup(client); - return nullptr; - } - return client; } } // namespace