Skip to content

Commit 7ab4068

Browse files
committed
Refactor token exchange parameters to be instance-specific in DatabricksTokenFederationProvider
1 parent efb9149 commit 7ab4068

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/databricks/sql/auth/token_federation.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515

1616
logger = logging.getLogger(__name__)
1717

18-
# Token exchange constants
19-
TOKEN_EXCHANGE_PARAMS = {
20-
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
21-
"scope": "sql",
22-
"subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
23-
"return_original_token_if_authenticated": "true",
24-
}
25-
2618

2719
class DatabricksTokenFederationProvider(CredentialsProvider):
2820
"""
@@ -40,6 +32,14 @@ class DatabricksTokenFederationProvider(CredentialsProvider):
4032
"Content-Type": "application/x-www-form-urlencoded",
4133
}
4234

35+
# Token exchange parameters
36+
TOKEN_EXCHANGE_PARAMS = {
37+
"grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
38+
"scope": "sql",
39+
"subject_token_type": "urn:ietf:params:oauth:token-type:jwt",
40+
"return_original_token_if_authenticated": "true",
41+
}
42+
4343
def __init__(
4444
self,
4545
credentials_provider: CredentialsProvider,
@@ -317,7 +317,7 @@ def _exchange_token(self, access_token: str) -> Token:
317317
ValueError: If token exchange fails
318318
"""
319319
# Prepare the request data
320-
token_exchange_data = dict(TOKEN_EXCHANGE_PARAMS)
320+
token_exchange_data = dict(self.TOKEN_EXCHANGE_PARAMS)
321321
token_exchange_data["subject_token"] = access_token
322322

323323
# Add client_id if provided

0 commit comments

Comments
 (0)