@@ -98,14 +98,28 @@ def get_retry_client(self):
9898 # Obtains an OAuth token from the API and sets the client headers accordingly
9999 def do_oauth (self ):
100100 try :
101- token_response = requests .post (
102- self .config ["oauth_url" ],
103- data = {"grant_type" :"client_credentials" },
104- auth = (
105- self .config ["client_id" ],
106- self .config ["client_secret" ]
107- ),
108- verify = self .lightbeam .config ["connection" ]["verify_ssl" ])
101+ try :
102+ token_response = requests .post (
103+ self .config ["oauth_url" ],
104+ data = {"grant_type" :"client_credentials" },
105+ auth = (
106+ self .config ["client_id" ],
107+ self .config ["client_secret" ]
108+ ),
109+ verify = self .lightbeam .config ["connection" ]["verify_ssl" ])
110+ except Exception as e :
111+ try :
112+ swapped_url = self .config ["oauth_url" ].replace ("http://" , "https://" ) if "http://" in self .config ["oauth_url" ] else self .config ["oauth_url" ].replace ("https://" , "http://" )
113+ token_response = requests .post (
114+ swapped_url ,
115+ data = {"grant_type" :"client_credentials" },
116+ auth = (
117+ self .config ["client_id" ],
118+ self .config ["client_secret" ]
119+ ),
120+ verify = self .lightbeam .config ["connection" ]["verify_ssl" ])
121+ except Exception as e :
122+ self .logger .critical (f"could not reach { self .config ['oauth_url' ]} ({ str (e )} )" )
109123 self .token = token_response .json ()["access_token" ]
110124 self .headers = {
111125 "accept" : "application/json" ,
0 commit comments