Skip to content
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

[Draft] change accomodating the potential uamqp changes #21038

Closed
Closed
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
8 changes: 5 additions & 3 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
MGMT_OPERATION,
MGMT_PARTITION_OPERATION,
MGMT_STATUS_CODE,
MGMT_STATUS_DESC
MGMT_STATUS_DESC,
AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -304,7 +305,7 @@ def _create_auth(self):
transport_type=self._config.transport_type,
custom_endpoint_hostname=self._config.custom_endpoint_hostname,
port=self._config.connection_port,
verify=self._config.connection_verify
verify=self._config.connection_verify,
)
auth.update_token()
return auth
Expand All @@ -318,7 +319,8 @@ def _create_auth(self):
transport_type=self._config.transport_type,
custom_endpoint_hostname=self._config.custom_endpoint_hostname,
port=self._config.connection_port,
verify=self._config.connection_verify
verify=self._config.connection_verify,
refresh_window=AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)

def _close_connection(self):
Expand Down
2 changes: 2 additions & 0 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@
b"com.microsoft:precondition-failed",
b"com.microsoft:argument-error",
)

AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS = 300
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
MGMT_OPERATION,
MGMT_PARTITION_OPERATION,
MGMT_STATUS_CODE,
MGMT_STATUS_DESC
MGMT_STATUS_DESC,
AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS
)
from ._connection_manager_async import get_connection_manager
from ._error_async import _handle_exception
Expand Down Expand Up @@ -182,7 +183,7 @@ async def _create_auth_async(self) -> authentication.JWTTokenAsync:
transport_type=self._config.transport_type,
custom_endpoint_hostname=self._config.custom_endpoint_hostname,
port=self._config.connection_port,
verify=self._config.connection_verify
verify=self._config.connection_verify,
)
await auth.update_token()
return auth
Expand All @@ -196,7 +197,8 @@ async def _create_auth_async(self) -> authentication.JWTTokenAsync:
transport_type=self._config.transport_type,
custom_endpoint_hostname=self._config.custom_endpoint_hostname,
port=self._config.connection_port,
verify=self._config.connection_verify
verify=self._config.connection_verify,
refresh_window=AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)

async def _close_connection_async(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,5 @@ class ServiceBusSubQueue(str, Enum):


NEXT_AVAILABLE_SESSION = ServiceBusSessionFilter.NEXT_AVAILABLE

AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS = 300
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
TRACE_ENQUEUED_TIME_PROPERTY,
SPAN_ENQUEUED_TIME_PROPERTY,
SPAN_NAME_RECEIVE,
AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)
from ..amqp import AmqpAnnotatedMessage

Expand Down Expand Up @@ -184,6 +185,7 @@ def create_authentication(client):
timeout=client._config.auth_timeout,
http_proxy=client._config.http_proxy,
transport_type=client._config.transport_type,
refresh_window=AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@

from uamqp import authentication

from .._common.constants import JWT_TOKEN_SCOPE, TOKEN_TYPE_JWT, TOKEN_TYPE_SASTOKEN
from .._common.constants import (
JWT_TOKEN_SCOPE,
TOKEN_TYPE_JWT,
TOKEN_TYPE_SASTOKEN,
AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)


_log = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,4 +69,5 @@ async def create_authentication(client):
timeout=client._config.auth_timeout,
http_proxy=client._config.http_proxy,
transport_type=client._config.transport_type,
refresh_window=AAD_TOKEN_REFRESH_WINDOW_IN_SECONDS,
)