|
15 | 15 | import requests |
16 | 16 |
|
17 | 17 | POSIT_OAUTH_INTEGRATION_AUTH_TYPE = "posit-oauth-integration" |
| 18 | +POSIT_LOCAL_CLIENT_CREDENTIALS_AUTH_TYPE = "posit-local-client-credentials" |
18 | 19 |
|
19 | 20 | # The Databricks SDK CredentialsProvider == Databricks SQL HeaderFactory |
20 | 21 | CredentialsProvider = Callable[[], Dict[str, str]] |
@@ -138,6 +139,26 @@ def __call__(self) -> Dict[str, str]: |
138 | 139 | credentials = self._client.oauth.get_credentials(self._user_session_token) |
139 | 140 | return _new_bearer_authorization_header(credentials) |
140 | 141 |
|
| 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 | + |
141 | 162 |
|
142 | 163 | class PositContentCredentialsStrategy(CredentialsStrategy): |
143 | 164 | """`CredentialsStrategy` implementation which supports interacting with Service Account OAuth integrations on Connect. |
|
0 commit comments