diff --git a/ingester-protocol/src/main/java/io/greptime/BulkWriteClient.java b/ingester-protocol/src/main/java/io/greptime/BulkWriteClient.java index 7386354..fc94aac 100644 --- a/ingester-protocol/src/main/java/io/greptime/BulkWriteClient.java +++ b/ingester-protocol/src/main/java/io/greptime/BulkWriteClient.java @@ -132,7 +132,7 @@ private BulkStreamWriter bulkStreamWriteTo( ctx.entrySet().forEach(e -> headers.insert(e.getKey(), String.valueOf(e.getValue()))); headers.insert(Keys.Headers.GREPTIMEDB_DBNAME, database); if (authInfo != null) { - headers.insert(Keys.Headers.GREPTIMEDB_AUTH, authInfo.toBase64()); + headers.insert(Keys.Headers.GREPTIMEDB_AUTH, authInfo.base64HeaderValue()); } HeaderCallOption headerOption = new HeaderCallOption(headers); AsyncExecCallOption execOption = new AsyncExecCallOption(this.asyncPool); diff --git a/ingester-protocol/src/main/java/io/greptime/models/AuthInfo.java b/ingester-protocol/src/main/java/io/greptime/models/AuthInfo.java index f8ed5b4..b5ab035 100644 --- a/ingester-protocol/src/main/java/io/greptime/models/AuthInfo.java +++ b/ingester-protocol/src/main/java/io/greptime/models/AuthInfo.java @@ -54,9 +54,11 @@ public static AuthInfo noAuthorization() { * * @return the base64 encoded string */ - public String toBase64() { - String authInfoStr = String.format("%s:%s", this.username, this.password); - return Base64.getEncoder().encodeToString(authInfoStr.getBytes(StandardCharsets.UTF_8)); + public String base64HeaderValue() { + String encoded = Base64.getEncoder() + .encodeToString( + String.format("%s:%s", this.username, this.password).getBytes(StandardCharsets.UTF_8)); + return String.format("Basic %s", encoded); } @Override