Skip to content

Commit

Permalink
Optionally allow basic auth
Browse files Browse the repository at this point in the history
This can be useful for setups of InfluxDB 1.8 without authentication when authentication is handled by a proxy instead.
  • Loading branch information
reinhard-brandstaedter committed May 26, 2021
1 parent a421a6f commit df847be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion influxdb_client/client/influxdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import absolute_import

import configparser
import os
import os, base64

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

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


retries = kwargs.get('retries', False)

self.api_client = ApiClient(configuration=conf, header_name=auth_header_name,
Expand Down

0 comments on commit df847be

Please sign in to comment.