Skip to content

Commit 29f95f2

Browse files
committed
Fix token refresh to use fresh token from provider
1 parent e6733cb commit 29f95f2

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/databricks/sql/auth/token_federation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,18 @@ def _refresh_token(self, access_token: str, token_type: str) -> Dict[str, str]:
275275
Dict[str, str]: Headers with the refreshed token
276276
"""
277277
try:
278-
# Exchange the token for a new one
279-
exchanged_token = self._exchange_token(access_token)
278+
# Get a fresh token from the underlying provider
279+
fresh_headers = self.credentials_provider()()
280+
281+
# Extract the fresh token from the headers
282+
fresh_token_type, fresh_access_token = self._extract_token_info_from_header(
283+
fresh_headers
284+
)
285+
286+
# Exchange the fresh token for a new Databricks token
287+
exchanged_token = self._exchange_token(fresh_access_token)
280288
self.last_exchanged_token = exchanged_token
281-
self.last_external_token = access_token
289+
self.last_external_token = fresh_access_token
282290

283291
# Update the headers with the new token
284292
return {

0 commit comments

Comments
 (0)