Skip to content

Commit 7b92d69

Browse files
sakshamgargMSSaksham Garg
andauthored
Add debug param for managedcleanroom login (#9612)
Co-authored-by: Saksham Garg <sakshamgarg@microsoft.com>
1 parent 9d242c5 commit 7b92d69

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/managedcleanroom/azext_managedcleanroom/_frontend_auth.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,21 @@ def get_frontend_token(cmd):
2424
:return: Tuple of (access_token, subscription, tenant)
2525
:raises: CLIError if token cannot be obtained
2626
"""
27+
import os
2728
from ._msal_auth import get_msal_token, get_auth_scope
2829

2930
profile = Profile(cli_ctx=cmd.cli_ctx)
3031
subscription = get_subscription_id(cmd.cli_ctx)
32+
33+
# Priority 0: explicit token via environment variable (for local/test envs only)
34+
env_token = os.environ.get('MANAGEDCLEANROOM_ACCESS_TOKEN')
35+
if env_token:
36+
logger.warning("Using token from MANAGEDCLEANROOM_ACCESS_TOKEN env var FOR TESTING PURPOSES ONLY")
37+
from collections import namedtuple
38+
AccessToken = namedtuple('AccessToken', ['token', 'expires_on'])
39+
token_obj = AccessToken(token=env_token, expires_on=0)
40+
return (token_obj, subscription, None)
41+
3142
auth_scope = get_auth_scope(cmd)
3243

3344
logger.debug("Using auth scope: %s", auth_scope)

0 commit comments

Comments
 (0)