Skip to content

Commit cc6d73d

Browse files
Update API
1 parent cbae014 commit cc6d73d

File tree

21 files changed

+726
-321
lines changed

21 files changed

+726
-321
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
779817ed8d63031f5ea761fbd25ee84f38feec0d
1+
05a10af4ed43566968119b43605f0a7fecbe780f

databricks/sdk/credentials_provider.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def oauth_service_principal(cfg: 'Config') -> Optional[CredentialsProvider]:
167167
oidc = cfg.oidc_endpoints
168168
if oidc is None:
169169
return None
170+
170171
token_source = ClientCredentials(client_id=cfg.client_id,
171172
client_secret=cfg.client_secret,
172173
token_url=oidc.token_endpoint,
@@ -210,16 +211,22 @@ def external_browser(cfg: 'Config') -> Optional[CredentialsProvider]:
210211
credentials = token_cache.load()
211212
if credentials:
212213
# Force a refresh in case the loaded credentials are expired.
213-
credentials.token()
214-
else:
215-
oauth_client = OAuthClient(oidc_endpoints=oidc_endpoints,
216-
client_id=client_id,
217-
redirect_url=redirect_url,
218-
client_secret=client_secret)
219-
consent = oauth_client.initiate_consent()
220-
if not consent:
221-
return None
222-
credentials = consent.launch_external_browser()
214+
# If the refresh fails, rather than throw exception we will initiate a new OAuth login flow.
215+
try:
216+
credentials.token()
217+
return credentials(cfg)
218+
# TODO: we should ideally use more specific exceptions.
219+
except Exception as e:
220+
logger.warning(f'Failed to refresh cached token: {e}. Initiating new OAuth login flow')
221+
222+
oauth_client = OAuthClient(oidc_endpoints=oidc_endpoints,
223+
client_id=client_id,
224+
redirect_url=redirect_url,
225+
client_secret=client_secret)
226+
consent = oauth_client.initiate_consent()
227+
if not consent:
228+
return None
229+
credentials = consent.launch_external_browser()
223230
token_cache.save(credentials)
224231
return credentials(cfg)
225232

databricks/sdk/service/cleanrooms.py

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

databricks/sdk/service/files.py

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

databricks/sdk/service/jobs.py

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

databricks/sdk/service/oauth2.py

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

0 commit comments

Comments
 (0)