Skip to content

Pass header to request session creation and remove obsolete @property in Bitbucket #1534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atlassian/bitbucket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def get_users_info(self, user_filter=None, start=0, limit=25):
params["filter"] = user_filter
return self._get_paged(url, params=params)

@property

def get_current_license(self):
"""
Retrieves details about the current license, as well as the current status of the system with
Expand Down
10 changes: 8 additions & 2 deletions atlassian/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def __init__(
max_backoff_retries: int = 1000,
backoff_factor=1.0,
backoff_jitter=1.0,
retry_with_header=True,
retry_with_header=True,
header=None
):
"""
init function for the AtlassianRestAPI object.
Expand Down Expand Up @@ -197,6 +198,8 @@ def __init__(
self._create_kerberos_session(kerberos)
elif cookies is not None:
self._session.cookies.update(cookies)
elif header is not None:
self._create_header_session(header)

def __enter__(self) -> Self:
return self
Expand All @@ -210,7 +213,10 @@ def _create_basic_session(self, username: str, password: str) -> None:
def _create_token_session(self, token: str) -> None:
self._update_header("Authorization", f"Bearer {token.strip()}")

def _create_kerberos_session(self, _: object) -> None:
def _create_header_session(self, header: dict) -> None:
self._session.headers.update(header)

def _create_kerberos_session(self, _):
from requests_kerberos import OPTIONAL, HTTPKerberosAuth

self._session.auth = HTTPKerberosAuth(mutual_authentication=OPTIONAL)
Expand Down
Loading