Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
project = 'semantic-link-labs'
copyright = '2024, Microsoft and community'
author = 'Microsoft and community'
release = '0.9.10'
release = '0.11.3'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name="semantic-link-labs"
authors = [
{ name = "Microsoft Corporation" },
]
version="0.9.10"
version="0.11.3"
description="Semantic Link Labs for Microsoft Fabric"
readme="README.md"
requires-python=">=3.10,<3.12"
Expand Down
33 changes: 25 additions & 8 deletions src/sempy_labs/_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from sempy._utils._log import log
from contextlib import contextmanager
import contextvars
from sempy.fabric._token_provider import SynapseTokenProvider


class ServicePrincipalTokenProvider(TokenProvider):
Expand Down Expand Up @@ -166,6 +167,20 @@ def _get_headers(
token_provider = contextvars.ContextVar("token_provider", default=None)


@contextmanager
def set_sp(token_provider):
prev_func = getattr(SynapseTokenProvider, "__call__")

def new_call(self, audience='pbi'):
return token_provider(audience=audience)

setattr(SynapseTokenProvider, "__call__", new_call)
try:
yield
finally:
setattr(SynapseTokenProvider, "__call__", prev_func)


@log
@contextmanager
def service_principal_authentication(
Expand Down Expand Up @@ -201,11 +216,13 @@ def service_principal_authentication(
key_vault_client_secret=key_vault_client_secret,
)
)
try:
yield
finally:
# Restore the prior state
if prior_token is None:
token_provider.set(None)
else:
token_provider.set(prior_token)

with set_sp(token_provider.get()):
try:
yield
finally:
# Restore the prior state
if prior_token is None:
token_provider.set(None)
else:
token_provider.set(prior_token)