surfdataverse 4.2.1__tar.gz → 4.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/PKG-INFO +1 -1
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/pyproject.toml +1 -1
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/src/surfdataverse/core.py +16 -15
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/README.md +0 -0
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/src/surfdataverse/__init__.py +0 -0
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/src/surfdataverse/container.py +0 -0
- {surfdataverse-4.2.1 → surfdataverse-4.2.2}/src/surfdataverse/exceptions.py +0 -0
|
@@ -200,32 +200,33 @@ class DataverseClient:
|
|
|
200
200
|
|
|
201
201
|
|
|
202
202
|
class MsalStorageCredential:
|
|
203
|
-
"""Azure TokenCredential
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
storage token is silent (no browser popup). Otherwise the browser opens once.
|
|
207
|
-
"""
|
|
203
|
+
"""Azure TokenCredential over one shared MSAL app + on-disk cache.
|
|
204
|
+
First resource opens a browser; every later resource — and every restart,
|
|
205
|
+
because the cache is persisted here — is silent."""
|
|
208
206
|
|
|
209
207
|
def __init__(self, client_id: str, authority: str):
|
|
210
|
-
|
|
208
|
+
self._cache, self._cache_file = get_token_cache()
|
|
211
209
|
self._app = msal.PublicClientApplication(
|
|
212
|
-
client_id, authority=authority, token_cache=
|
|
210
|
+
client_id, authority=authority, token_cache=self._cache
|
|
213
211
|
)
|
|
214
212
|
|
|
215
213
|
def get_token(self, *scopes, **kwargs) -> AccessToken:
|
|
216
|
-
scope = list(scopes) if scopes else [kwargs
|
|
214
|
+
scope = list(scopes) if scopes else [kwargs["scope"]]
|
|
217
215
|
result = None
|
|
218
|
-
accounts
|
|
219
|
-
|
|
220
|
-
result = self._app.acquire_token_silent(scopes=scope, account=accounts[0])
|
|
216
|
+
if accounts := self._app.get_accounts():
|
|
217
|
+
result = self._app.acquire_token_silent(scope, account=accounts[0])
|
|
221
218
|
if not result:
|
|
222
219
|
result = self._app.acquire_token_interactive(scope)
|
|
223
220
|
if "access_token" not in result:
|
|
224
|
-
raise
|
|
225
|
-
f"
|
|
221
|
+
raise AuthenticationError(
|
|
222
|
+
f"Authentication failed for {scope}: "
|
|
223
|
+
f"{result.get('error_description', result.get('error'))}"
|
|
226
224
|
)
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
if self._cache.has_state_changed: # persist for ALL consumers
|
|
226
|
+
self._cache_file.write_text(self._cache.serialize())
|
|
227
|
+
return AccessToken(
|
|
228
|
+
result["access_token"], int(time.time()) + result.get("expires_in", 3600)
|
|
229
|
+
)
|
|
229
230
|
|
|
230
231
|
|
|
231
232
|
class DataverseBase:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|