|
20 | 20 | """
|
21 | 21 |
|
22 | 22 | import json
|
| 23 | +import base64 |
23 | 24 | import logging
|
24 | 25 | from datetime import datetime
|
25 | 26 | from typing import Any, Dict, List, Literal, Optional, Union
|
@@ -318,7 +319,8 @@ def assemble_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
318 | 319 | auth_type = values.get("auth_type")
|
319 | 320 | if auth_type:
|
320 | 321 | if auth_type.lower() == "basic":
|
321 |
| - encoded_auth = encode_auth({"username": values.get("auth_username", ""), "password": values.get("auth_password", "")}) |
| 322 | + creds = base64.b64encode(f'{values.get("auth_username", "")}:{values.get("auth_password", "")}'.encode("utf-8")).decode() |
| 323 | + encoded_auth = encode_auth({"Authorization": f"Basic {creds}"}) |
322 | 324 | values["auth"] = {"auth_type": "basic", "auth_value": encoded_auth}
|
323 | 325 | elif auth_type.lower() == "bearer":
|
324 | 326 | encoded_auth = encode_auth({"Authorization": f"Bearer {values.get('auth_token', '')}"})
|
@@ -376,7 +378,8 @@ def assemble_auth(cls, values: Dict[str, Any]) -> Dict[str, Any]:
|
376 | 378 | auth_type = values.get("auth_type")
|
377 | 379 | if auth_type:
|
378 | 380 | if auth_type.lower() == "basic":
|
379 |
| - encoded_auth = encode_auth({"username": values.get("auth_username", ""), "password": values.get("auth_password", "")}) |
| 381 | + creds = base64.b64encode(f'{values.get("auth_username", "")}:{values.get("auth_password", "")}'.encode("utf-8")).decode() |
| 382 | + encoded_auth = encode_auth({"Authorization": f"Basic {creds}"}) |
380 | 383 | values["auth"] = {"auth_type": "basic", "auth_value": encoded_auth}
|
381 | 384 | elif auth_type.lower() == "bearer":
|
382 | 385 | encoded_auth = encode_auth({"Authorization": f"Bearer {values.get('auth_token', '')}"})
|
@@ -715,7 +718,8 @@ def _process_auth_fields(values: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
715 | 718 | if not username or not password:
|
716 | 719 | raise ValueError("For 'basic' auth, both 'auth_username' and 'auth_password' must be provided.")
|
717 | 720 |
|
718 |
| - return encode_auth({"username": username, "password": password}) |
| 721 | + creds = base64.b64encode(f'{username}:{password}'.encode("utf-8")).decode() |
| 722 | + return encode_auth({"Authorization": f"Basic {creds}"}) |
719 | 723 |
|
720 | 724 | if auth_type == "bearer":
|
721 | 725 | # For bearer authentication, only token is required
|
@@ -824,7 +828,8 @@ def _process_auth_fields(values: Dict[str, Any]) -> Optional[Dict[str, Any]]:
|
824 | 828 | if not username or not password:
|
825 | 829 | raise ValueError("For 'basic' auth, both 'auth_username' and 'auth_password' must be provided.")
|
826 | 830 |
|
827 |
| - return encode_auth({"username": username, "password": password}) |
| 831 | + creds = base64.b64encode(f"{username}:{password}".encode("utf-8")).decode() |
| 832 | + return encode_auth({"Authorization": f"Basic {creds}"}) |
828 | 833 |
|
829 | 834 | if auth_type == "bearer":
|
830 | 835 | # For bearer authentication, only token is required
|
|
0 commit comments