Updated argument handling for get-token.py.
All checks were successful
/ unit-tests (push) Successful in 9s

This commit is contained in:
2025-11-09 10:59:19 +01:00
parent 495ba0b0b3
commit d06bc05a2d

View File

@@ -17,15 +17,20 @@ Usage:
from sk.azure import get_token
from argparse import ArgumentParser
import os
args = ArgumentParser(description="Get Azure DevOps token and print it for exporting as environment variable.")
args.add_argument("--tenant-id", type=str, required=True, help="Azure AD Tenant ID")
args.add_argument("--client-id", type=str, required=True, help="Azure AD Client ID")
args.add_argument("--pem-path", type=str, help="Path to PEM file for authentication (optional)")
args.add_argument("--client-secret", type=str, help="Client Secret for authentication (optional)")
args.add_argument("--tenant-id", type=str, default=os.getenv("AZURE_TENANT_ID"), help="Azure AD Tenant ID")
args.add_argument("--client-id", type=str, default=os.getenv("AZURE_CLIENT_ID"), help="Azure AD Client ID")
args.add_argument("--pem-path", type=str, default=os.getenv("AZURE_CLIENT_CERTIFICATE_PATH"), help="Path to PEM file for authentication (optional)")
args.add_argument("--client-secret", type=str, default=os.getenv("AZURE_CLIENT_SECRET"), help="Client Secret for authentication (optional)")
args = args.parse_args()
if args.pem_path:
if not args.tenant_id or not args.client_id:
print("Tenant ID and Client ID are required.")
exit(1)
if args.pem_path and os.path.isfile(args.pem_path):
token = get_token(
tenant_id=args.tenant_id,
client_id=args.client_id,