Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Knightley authored and Jacob Knightley committed Jan 2, 2025
1 parent 4d3d3be commit 458e2ee
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 43 deletions.
8 changes: 0 additions & 8 deletions .vscode/extensions.json

This file was deleted.

34 changes: 0 additions & 34 deletions .vscode/settings.json

This file was deleted.

25 changes: 25 additions & 0 deletions src/fabric_cicd/_common/_fabric_endpoint copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from azure.identity import DefaultAzureCredential

def _refresh_token():
credential = DefaultAzureCredential(exclude_azure_powershell_credential=True)
resource_url = "https://api.fabric.microsoft.com"

self.aad_token = credential.get_token(resource_url).token

try:
parts = self.aad_token.split(".")
payload = parts[1]
padding = "=" * (4 - len(payload) % 4)
payload += padding
decoded = base64.urlsafe_b64decode(payload.encode("utf-8"))
expiration = json.loads(decoded).get("exp")

if expiration:
self.aad_token_expiration = datetime.datetime.fromtimestamp(
expiration
)
else:
print("Token does not contain expiration claim.")


_refresh_token()
2 changes: 1 addition & 1 deletion src/fabric_cicd/_common/_fabric_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _refresh_token(self):
or self.aad_token_expiration is None
or self.aad_token_expiration < datetime.datetime.utcnow()
):
credential = DefaultAzureCredential()
credential = DefaultAzureCredential(exclude_azure_powershell_credential=True))
resource_url = "https://api.fabric.microsoft.com"

self.aad_token = credential.get_token(resource_url).token
Expand Down

0 comments on commit 458e2ee

Please sign in to comment.