kevinjqliu commented on issue #2328:
URL:
https://github.com/apache/iceberg-python/issues/2328#issuecomment-3190217864
Heres a workaround to make Entra/AAD token work like
`DefaultAzureCredential` inside Fabric notebook env
```
from azure.core.credentials import AccessToken, TokenCredential
from datetime import datetime, timedelta
class UserTokenCredential(TokenCredential):
def __init__(self, token: str, expires_on: datetime = None):
self._token = token
self._expires_on = expires_on or (datetime.utcnow() +
timedelta(hours=1))
def get_token(self, *scopes, **kwargs):
return AccessToken(self._token, int(self._expires_on.timestamp()))
token = notebookutils.credentials.getToken('storage')
token_credential = UserTokenCredential(token)
# Example: passing to a BlobServiceClient
from azure.storage.blob import BlobServiceClient
client =
BlobServiceClient(account_url="https://<account>.blob.core.windows.net",
credential=token_credential)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]