4646 * <ul>
4747 * <li><code>host</code> - hostname or IP address of the InfluxDB server</li>
4848 * <li><code>token</code> - authentication token for accessing the InfluxDB server</li>
49+ * <li><code>authScheme</code> - authentication scheme</li>
4950 * <li><code>organization</code> - organization to be used for operations</li>
5051 * <li><code>database</code> - database to be used for InfluxDB operations</li>
5152 * <li><code>writePrecision</code> - precision to use when writing points to InfluxDB</li>
@@ -86,6 +87,7 @@ public final class ClientConfig {
8687
8788 private final String host ;
8889 private final char [] token ;
90+ private final String authScheme ;
8991 private final String organization ;
9092 private final String database ;
9193 private final WritePrecision writePrecision ;
@@ -118,6 +120,16 @@ public char[] getToken() {
118120 return token ;
119121 }
120122
123+ /**
124+ * Gets authentication scheme.
125+ *
126+ * @return authentication scheme, may be null
127+ */
128+ @ Nullable
129+ public String getAuthScheme () {
130+ return authScheme ;
131+ }
132+
121133 /**
122134 * Gets organization to be used for operations.
123135 *
@@ -247,6 +259,7 @@ public boolean equals(final Object o) {
247259 ClientConfig that = (ClientConfig ) o ;
248260 return Objects .equals (host , that .host )
249261 && Arrays .equals (token , that .token )
262+ && Objects .equals (authScheme , that .authScheme )
250263 && Objects .equals (organization , that .organization )
251264 && Objects .equals (database , that .database )
252265 && writePrecision == that .writePrecision
@@ -262,7 +275,7 @@ public boolean equals(final Object o) {
262275
263276 @ Override
264277 public int hashCode () {
265- return Objects .hash (host , Arrays .hashCode (token ), organization ,
278+ return Objects .hash (host , Arrays .hashCode (token ), authScheme , organization ,
266279 database , writePrecision , gzipThreshold ,
267280 timeout , allowHttpRedirects , disableServerCertificateValidation ,
268281 proxy , authenticator , headers ,
@@ -295,6 +308,7 @@ public String toString() {
295308 public static final class Builder {
296309 private String host ;
297310 private char [] token ;
311+ private String authScheme ;
298312 private String organization ;
299313 private String database ;
300314 private WritePrecision writePrecision ;
@@ -333,6 +347,20 @@ public Builder token(@Nullable final char[] token) {
333347 return this ;
334348 }
335349
350+ /**
351+ * Sets authentication scheme.
352+ *
353+ * @param authScheme authentication scheme.
354+ * Default <code>null</code> for Cloud access, set to 'Bearer' for Edge.
355+ * @return this
356+ */
357+ @ Nonnull
358+ public Builder authScheme (@ Nullable final String authScheme ) {
359+
360+ this .authScheme = authScheme ;
361+ return this ;
362+ }
363+
336364 /**
337365 * Sets organization to be used for operations.
338366 *
@@ -525,6 +553,9 @@ public ClientConfig build(@Nonnull final String connectionString) throws Malform
525553 if (parameters .containsKey ("token" )) {
526554 this .token (parameters .get ("token" ).toCharArray ());
527555 }
556+ if (parameters .containsKey ("authScheme" )) {
557+ this .authScheme (parameters .get ("authScheme" ));
558+ }
528559 if (parameters .containsKey ("org" )) {
529560 this .organization (parameters .get ("org" ));
530561 }
@@ -565,6 +596,10 @@ public ClientConfig build(@Nonnull final Map<String, String> env, final Properti
565596 if (token != null ) {
566597 this .token (token .toCharArray ());
567598 }
599+ final String authScheme = get .apply ("INFLUX_AUTH_SCHEME" , "influx.authScheme" );
600+ if (authScheme != null ) {
601+ this .authScheme (authScheme );
602+ }
568603 final String org = get .apply ("INFLUX_ORG" , "influx.org" );
569604 if (org != null ) {
570605 this .organization (org );
@@ -612,6 +647,7 @@ private WritePrecision parsePrecision(@Nonnull final String precision) {
612647 private ClientConfig (@ Nonnull final Builder builder ) {
613648 host = builder .host ;
614649 token = builder .token ;
650+ authScheme = builder .authScheme ;
615651 organization = builder .organization ;
616652 database = builder .database ;
617653 writePrecision = builder .writePrecision != null ? builder .writePrecision : WritePrecision .NS ;
0 commit comments