Skip to content

Commit 91877ee

Browse files
committed
add implementing strategy that can use local credentials provider
1 parent 73569a3 commit 91877ee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/posit/connect/external/databricks.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import requests
1616

1717
POSIT_OAUTH_INTEGRATION_AUTH_TYPE = "posit-oauth-integration"
18+
POSIT_LOCAL_CLIENT_CREDENTIALS_AUTH_TYPE = "posit-local-client-credentials"
1819

1920
# The Databricks SDK CredentialsProvider == Databricks SQL HeaderFactory
2021
CredentialsProvider = Callable[[], Dict[str, str]]
@@ -138,6 +139,26 @@ def __call__(self) -> Dict[str, str]:
138139
credentials = self._client.oauth.get_credentials(self._user_session_token)
139140
return _new_bearer_authorization_header(credentials)
140141

142+
class PositLocalContentCredentialsStrategy(CredentialsStrategy):
143+
def __init__(self, token_endpoint_url: str, client_id: str, client_secret: str):
144+
self._token_endpoint_url = token_endpoint_url
145+
self._client_id = client_id
146+
self._client_secret = client_secret
147+
148+
def sql_credentials_provider(self, *args, **kwargs):
149+
return lambda: self.__call__(*args, **kwargs)
150+
151+
def auth_type(self) -> str:
152+
return POSIT_LOCAL_CLIENT_CREDENTIALS_AUTH_TYPE
153+
154+
def __call__(self) -> CredentialsProvider:
155+
156+
return PositLocalContentCredentialsProvider(
157+
self._token_endpoint_url,
158+
self._client_id,
159+
self._client_secret,
160+
)
161+
141162

142163
class PositContentCredentialsStrategy(CredentialsStrategy):
143164
"""`CredentialsStrategy` implementation which supports interacting with Service Account OAuth integrations on Connect.

0 commit comments

Comments
 (0)