Skip to content

Commit 62e6a7e

Browse files
Enable async token refresh by default (#952)
## What changes are proposed in this pull request? Enable async token refresh by default. ## How is this tested? Integration test will now run using async token refresh. --------- Signed-off-by: hectorcast-db <[email protected]> Co-authored-by: Renaud Hartert <[email protected]>
1 parent 1f3ecce commit 62e6a7e

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

NEXT_CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
## Release v0.51.0
44

55
### New Features and Improvements
6+
* Enabled asynchronous token refreshes by default. A new `disable_async_token_refresh` configuration option has been added to allow disabling this feature if necessary ([#952](https://github.com/databricks/databricks-sdk-py/pull/952)).
7+
To disable asynchronous token refresh, set the environment variable `DATABRICKS_DISABLE_ASYNC_TOKEN_REFRESH=true` or configure it within your configuration object.
8+
The previous `enable_experimental_async_token_refresh` option has been removed as asynchronous refresh is now the default behavior.
69

710
### Bug Fixes
811

databricks/sdk/__init__.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

databricks/sdk/config.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ class Config:
9595
max_connections_per_pool: int = ConfigAttribute()
9696
databricks_environment: Optional[DatabricksEnvironment] = None
9797

98-
enable_experimental_async_token_refresh: bool = ConfigAttribute(
99-
env="DATABRICKS_ENABLE_EXPERIMENTAL_ASYNC_TOKEN_REFRESH"
100-
)
98+
disable_async_token_refresh: bool = ConfigAttribute(env="DATABRICKS_DISABLE_ASYNC_TOKEN_REFRESH")
10199

102100
enable_experimental_files_api_client: bool = ConfigAttribute(env="DATABRICKS_ENABLE_EXPERIMENTAL_FILES_API_CLIENT")
103101
files_api_client_download_max_total_recovers = None

databricks/sdk/credentials_provider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def oauth_service_principal(cfg: "Config") -> Optional[CredentialsProvider]:
191191
token_url=oidc.token_endpoint,
192192
scopes=["all-apis"],
193193
use_header=True,
194-
disable_async=not cfg.enable_experimental_async_token_refresh,
194+
disable_async=cfg.disable_async_token_refresh,
195195
)
196196

197197
def inner() -> Dict[str, str]:
@@ -291,7 +291,7 @@ def token_source_for(resource: str) -> TokenSource:
291291
token_url=f"{aad_endpoint}{cfg.azure_tenant_id}/oauth2/token",
292292
endpoint_params={"resource": resource},
293293
use_params=True,
294-
disable_async=not cfg.enable_experimental_async_token_refresh,
294+
disable_async=cfg.disable_async_token_refresh,
295295
)
296296

297297
_ensure_host_present(cfg, token_source_for)
@@ -357,7 +357,7 @@ def github_oidc_azure(cfg: "Config") -> Optional[CredentialsProvider]:
357357
token_url=f"{aad_endpoint}{cfg.azure_tenant_id}/oauth2/token",
358358
endpoint_params=params,
359359
use_params=True,
360-
disable_async=not cfg.enable_experimental_async_token_refresh,
360+
disable_async=cfg.disable_async_token_refresh,
361361
)
362362

363363
def refreshed_headers() -> Dict[str, str]:
@@ -694,7 +694,7 @@ def __init__(self, cfg: "Config"):
694694
token_type_field="token_type",
695695
access_token_field="access_token",
696696
expiry_field="expiry",
697-
disable_async=not cfg.enable_experimental_async_token_refresh,
697+
disable_async=cfg.disable_async_token_refresh,
698698
)
699699

700700
@staticmethod

0 commit comments

Comments
 (0)