Merge pull request #12651 from thingsboard/fix/http-basic-auth

Fix Basic auth in REST API call node
This commit is contained in:
Viacheslav Klimov 2025-02-10 16:02:23 +02:00 committed by GitHub
commit 3eaa885f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -343,7 +343,7 @@ public class TbHttpClient {
if (CredentialsType.BASIC == credentials.getType()) { if (CredentialsType.BASIC == credentials.getType()) {
BasicCredentials basicCredentials = (BasicCredentials) credentials; BasicCredentials basicCredentials = (BasicCredentials) credentials;
String authString = basicCredentials.getUsername() + ":" + basicCredentials.getPassword(); String authString = basicCredentials.getUsername() + ":" + basicCredentials.getPassword();
String encodedAuthString = new String(Base64.getDecoder().decode(authString.getBytes(StandardCharsets.UTF_8))); String encodedAuthString = new String(Base64.getEncoder().encode(authString.getBytes(StandardCharsets.UTF_8)));
headers.add("Authorization", "Basic " + encodedAuthString); headers.add("Authorization", "Basic " + encodedAuthString);
} }
} }