Skip to content

Commit

Permalink
feat: optional parameter to allow basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
reinhard-brandstaedter committed May 26, 2021
1 parent df847be commit 8c23958
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions influxdb_client/client/influxdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
from __future__ import absolute_import

import configparser
import os, base64
import os
import base64

from influxdb_client import Configuration, ApiClient, HealthCheck, HealthService, Ready, ReadyService
from influxdb_client.client.authorizations_api import AuthorizationsApi
Expand Down Expand Up @@ -66,12 +67,10 @@ 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 8c23958

Please sign in to comment.