Skip to content

Commit

Permalink
add exception for edge case where we couldn't get tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrg committed Jul 30, 2023
1 parent 171adea commit 18ef94d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/powerpwn/powerdump/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ def acquire_token(scope: str, tenant: Optional[str] = None) -> str:
)
)

bearer = azure_cli_bearer_tokens_for_scope.get("token_type") + " " + azure_cli_bearer_tokens_for_scope.get("access_token")
if "token_type" not in azure_cli_bearer_tokens_for_scope or "access_token" not in azure_cli_bearer_tokens_for_scope:
logger.debug(
f"Acquired a token package with scope={scope}, tenant={tenant}. Received the following keys: {list(azure_cli_bearer_tokens_for_scope.key())}."
)
raise RuntimeError(f"Something went wrong when trying to fetch tokens with scope={scope}, tenant={tenant}. Try removing cached credentials.")

bearer = azure_cli_bearer_tokens_for_scope["token_type"] + " " + azure_cli_bearer_tokens_for_scope["access_token"]
logger.info(f"Access token for {scope} acquired successfully")

# cache refresh token for cli to use in further FOCI authentication
Expand Down

0 comments on commit 18ef94d

Please sign in to comment.