diff --git a/docs/source/index.rst b/docs/source/index.rst
index f524920..af697da 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -92,6 +92,14 @@ Main methods::
                         client_secret_key="secret",
                         verify=True)
 
+    # Optionally, you can pass custom headers that will be added to all HTTP calls
+    # keycloak_openid = KeycloakOpenID(server_url="http://localhost:8080/auth/",
+    #                    client_id="example_client",
+    #                    realm_name="example_realm",
+    #                    client_secret_key="secret",
+    #                    verify=True,
+    #                    custom_headers={'CustomHeader': 'value'})
+
     # Get WellKnow
     config_well_know = keycloak_openid.well_know()
 
@@ -143,6 +151,14 @@ Main methods::
                                    realm_name="example_realm",
                                    verify=True)
 
+    # Optionally, you can pass custom headers that will be added to all HTTP calls
+    #keycloak_admin = KeycloakAdmin(server_url="http://localhost:8080/auth/",
+    #                               username='example-admin',
+    #                               password='secret',
+    #                               realm_name="example_realm",
+    #                               verify=True,
+    #                               custom_headers={'CustomHeader': 'value'})
+
     # Add user
     new_user = keycloak_admin.create_user({"email": "example@example.com",
                         "username": "example@example.com",
diff --git a/keycloak/keycloak_admin.py b/keycloak/keycloak_admin.py
index c707ba6..5c6fe69 100644
--- a/keycloak/keycloak_admin.py
+++ b/keycloak/keycloak_admin.py
@@ -45,7 +45,8 @@ class KeycloakAdmin:
 
     PAGE_SIZE = 100
 
-    def __init__(self, server_url, username, password, realm_name='master', client_id='admin-cli', verify=True, client_secret_key=None):
+    def __init__(self, server_url, username, password, realm_name='master', client_id='admin-cli', verify=True,
+                 client_secret_key=None, custom_headers=None):
         """
 
         :param server_url: Keycloak server url
@@ -55,6 +56,7 @@ class KeycloakAdmin:
         :param client_id: client id
         :param verify: True if want check connection SSL
         :param client_secret_key: client secret key
+        :param custom_headers: dict of custom header to pass to each HTML request
         """
         self._username = username
         self._password = password
@@ -63,15 +65,23 @@ class KeycloakAdmin:
 
         # Get token Admin
         keycloak_openid = KeycloakOpenID(server_url=server_url, client_id=client_id, realm_name=realm_name,
-                                         verify=verify, client_secret_key=client_secret_key)
+                                         verify=verify, client_secret_key=client_secret_key,
+                                         custom_headers=custom_headers)
 
         grant_type = ["password"]
         if client_secret_key:
             grant_type = ["client_credentials"]
         self._token = keycloak_openid.token(username, password, grant_type=grant_type)
+        headers = {
+            'Authorization': 'Bearer ' + self.token.get('access_token'),
+            'Content-Type': 'application/json'
+        }
+        if custom_headers is not None:
+            # merge custom headers to main headers
+            headers.update(custom_headers)
+
         self._connection = ConnectionManager(base_url=server_url,
-                                             headers={'Authorization': 'Bearer ' + self.token.get('access_token'),
-                                                      'Content-Type': 'application/json'},
+                                             headers=headers,
                                              timeout=60,
                                              verify=verify)
 
diff --git a/keycloak/keycloak_openid.py b/keycloak/keycloak_openid.py
index 61703e7..b196a85 100644
--- a/keycloak/keycloak_openid.py
+++ b/keycloak/keycloak_openid.py
@@ -43,7 +43,7 @@ from .urls_patterns import (
 
 class KeycloakOpenID:
 
-    def __init__(self, server_url, realm_name, client_id, client_secret_key=None, verify=True):
+    def __init__(self, server_url, realm_name, client_id, client_secret_key=None, verify=True, custom_headers=None):
         """
 
         :param server_url: Keycloak server url
@@ -51,12 +51,17 @@ class KeycloakOpenID:
         :param realm_name: realm name
         :param client_secret_key: client secret key
         :param verify: True if want check connection SSL
+        :param custom_headers: dict of custom header to pass to each HTML request
         """
         self._client_id = client_id
         self._client_secret_key = client_secret_key
         self._realm_name = realm_name
+        headers = dict()
+        if custom_headers is not None:
+            # merge custom headers to main headers
+            headers.update(custom_headers)
         self._connection = ConnectionManager(base_url=server_url,
-                                             headers={},
+                                             headers=headers,
                                              timeout=60,
                                              verify=verify)
 

Feature request: add custom headers to requests
Keycloak can be placed behind a reverse proxy that require some custom header to be present for security reason.
It would be nice to have an option to add those custom headers to objects creation
diff --git a/keycloak/tests/test_connection.py b/keycloak/tests/test_connection.py
index 69496f1..4c54183 100644
--- a/keycloak/tests/test_connection.py
+++ b/keycloak/tests/test_connection.py
@@ -14,9 +14,11 @@
 #
 # You should have received a copy of the GNU Lesser General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+from unittest import mock
 
 from httmock import urlmatch, response, HTTMock, all_requests
 
+from keycloak import KeycloakAdmin, KeycloakOpenID
 from ..connection import ConnectionManager
 
 try:
@@ -141,3 +143,47 @@ class TestConnection(unittest.TestCase):
         self._conn.add_param_headers("test", "value")
         self.assertEqual(self._conn.headers,
                          {"test": "value"})
+
+    def test_KeycloakAdmin_custom_header(self):
+
+        class FakeToken:
+            @staticmethod
+            def get(string_val):
+                return "faketoken"
+
+        fake_token = FakeToken()
+
+        with mock.patch.object(KeycloakOpenID, "__init__", return_value=None) as mock_keycloak_open_id:
+            with mock.patch("keycloak.keycloak_openid.KeycloakOpenID.token", return_value=fake_token):
+                with mock.patch("keycloak.connection.ConnectionManager.__init__", return_value=None) as mock_connection_manager:
+                    server_url = "https://localhost/auth/"
+                    username = "admin"
+                    password = "secret"
+                    realm_name = "master"
+
+                    headers = {
+                        'Custom': 'test-custom-header'
+                    }
+                    KeycloakAdmin(server_url=server_url,
+                                  username=username,
+                                  password=password,
+                                  realm_name=realm_name,
+                                  verify=False,
+                                  custom_headers=headers)
+
+                    mock_keycloak_open_id.assert_called_with(server_url=server_url,
+                                                             realm_name=realm_name,
+                                                             client_id='admin-cli',
+                                                             client_secret_key=None,
+                                                             verify=False,
+                                                             custom_headers=headers)
+
+                    expected_header = {'Authorization': 'Bearer faketoken',
+                                       'Content-Type': 'application/json',
+                                       'Custom': 'test-custom-header'
+                                       }
+
+                    mock_connection_manager.assert_called_with(base_url=server_url,
+                                                               headers=expected_header,
+                                                               timeout=60,
+                                                               verify=False)

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest httmock
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
bleach==6.0.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
docutils==0.20.1
ecdsa==0.19.1
exceptiongroup==1.2.2
httmock==1.4.0
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pkginfo==1.10.0
pluggy==1.2.0
pyasn1==0.4.8
Pygments==2.17.2
pytest==7.4.4
python-jose==3.4.0
-e git+https://github.com/marcospereirampj/python-keycloak.git@73544819dbc76dbae096242085296e248b8c2e03#egg=python_keycloak
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
rsa==4.9
six==1.17.0
tomli==2.0.1
tqdm==4.67.1
twine==1.13.0
typing_extensions==4.7.1
urllib3==2.0.7
webencodings==0.5.1
zipp==3.15.0

name: python-keycloak
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - bleach==6.0.0
      - charset-normalizer==3.4.1
      - docutils==0.20.1
      - ecdsa==0.19.1
      - exceptiongroup==1.2.2
      - httmock==1.4.0
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pkginfo==1.10.0
      - pluggy==1.2.0
      - pyasn1==0.4.8
      - pygments==2.17.2
      - pytest==7.4.4
      - python-jose==3.4.0
      - readme-renderer==37.3
      - requests==2.31.0
      - requests-toolbelt==1.0.0
      - rsa==4.9
      - six==1.17.0
      - tomli==2.0.1
      - tqdm==4.67.1
      - twine==1.13.0
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - webencodings==0.5.1
      - zipp==3.15.0
prefix: /opt/conda/envs/python-keycloak

keycloak/tests/test_connection.py::TestConnection::test_KeycloakAdmin_custom_header
keycloak/tests/test_connection.py::TestConnection::test_add_param_headers keycloak/tests/test_connection.py::TestConnection::test_clean_param_headers keycloak/tests/test_connection.py::TestConnection::test_del_param_headers keycloak/tests/test_connection.py::TestConnection::test_exist_param_headers keycloak/tests/test_connection.py::TestConnection::test_get_headers keycloak/tests/test_connection.py::TestConnection::test_get_param_headers keycloak/tests/test_connection.py::TestConnection::test_raw_get keycloak/tests/test_connection.py::TestConnection::test_raw_get_fail keycloak/tests/test_connection.py::TestConnection::test_raw_post keycloak/tests/test_connection.py::TestConnection::test_raw_post_fail keycloak/tests/test_connection.py::TestConnection::test_raw_put keycloak/tests/test_connection.py::TestConnection::test_raw_put_fail
keycloak/keycloak_admin.py keycloak/keycloak_openid.py docs/source/index.rst
keycloak/keycloak_admin.py keycloak/keycloak_openid.py docs/source/index.rst