Skip to content

Commit df847be

Browse files
Optionally allow basic auth
This can be useful for setups of InfluxDB 1.8 without authentication when authentication is handled by a proxy instead.
1 parent a421a6f commit df847be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

influxdb_client/client/influxdb_client.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import absolute_import
44

55
import configparser
6-
import os
6+
import os, base64
77

88
from influxdb_client import Configuration, ApiClient, HealthCheck, HealthService, Ready, ReadyService
99
from influxdb_client.client.authorizations_api import AuthorizationsApi
@@ -66,6 +66,12 @@ def __init__(self, url, token, debug=None, timeout=10_000, enable_gzip=False, or
6666
auth_header_name = "Authorization"
6767
auth_header_value = "Token " + auth_token
6868

69+
# allow basic authentication for cases where InfluxDB (backwards 1.8 doesn't use auth but proxies perform basic auth)
70+
auth_basic = kwargs.get('auth_basic', False)
71+
if auth_basic:
72+
auth_header_value = "Basic " + base64.b64encode(token.encode()).decode()
73+
74+
6975
retries = kwargs.get('retries', False)
7076

7177
self.api_client = ApiClient(configuration=conf, header_name=auth_header_name,

0 commit comments

Comments
 (0)