4
4
import json
5
5
import logging
6
6
from azure_func import azure_imports
7
- from azure .identity import ClientSecretCredential , CertificateCredential
7
+ from azure .identity import ClientSecretCredential , CertificateCredential , InteractiveBrowserCredential
8
8
9
9
class CustomEncoder (json .JSONEncoder ):
10
10
def default (self , obj ):
@@ -22,7 +22,8 @@ def parse_arguments():
22
22
parser .add_argument ('--client_secret' , type = str , required = False , help = 'Client Secret' )
23
23
parser .add_argument ('--certificate_path' , type = str , required = False , help = 'Path to the certificate file' )
24
24
parser .add_argument ('--use_device_code' , action = 'store_true' , help = 'Use device code authentication' )
25
-
25
+ parser .add_argument ('--interactive_login' , action = 'store_true' , help = 'Use interactive login' )
26
+
26
27
#filter args
27
28
parser .add_argument ('--subscription_id' , type = str , required = False , help = 'Subscription ID' )
28
29
parser .add_argument ('--resource_group' , type = str , required = False , help = 'Resource Group' )
@@ -63,8 +64,10 @@ def initialize_data():
63
64
64
65
return data , start_time
65
66
66
- def authenticate_to_azure (tenant_id , client_id , client_secret = None , certificate_path = None , use_device_code = False ):
67
- if use_device_code :
67
+ def authenticate_to_azure (tenant_id , client_id , client_secret = None , certificate_path = None , use_device_code = None , interactive_login = False ):
68
+ if interactive_login :
69
+ credential = InteractiveBrowserCredential (client_id = client_id )
70
+ elif use_device_code :
68
71
# Use DeviceCodeCredential when use_device_code is True
69
72
credential = azure_imports .DeviceCodeCredential (client_id = client_id , tenant_id = tenant_id )
70
73
elif certificate_path :
0 commit comments