@@ -103,19 +103,16 @@ def initialise_api(
103103 if config .debug :
104104 click .echo ("User API key config value set" )
105105
106- if headers :
107- if "Authorization" in config .headers :
108- auth_header_value = config .headers ["Authorization" ]
109- # Only parse if it looks like a valid Authorization header
110- if auth_header_value and " " in auth_header_value :
111- auth_type , encoded = auth_header_value .split (" " , 1 )
112- if auth_type == "Basic" :
113- decoded = base64 .b64decode (encoded )
114- values = decoded .decode ("utf-8" )
115- config .username , config .password = values .split (":" )
116-
117- if config .debug :
118- click .echo ("Username and password config values set" )
106+ auth_header = headers and config .headers .get ("Authorization" )
107+ if auth_header and " " in auth_header :
108+ auth_type , encoded = auth_header .split (" " , 1 )
109+ if auth_type == "Basic" :
110+ decoded = base64 .b64decode (encoded )
111+ values = decoded .decode ("utf-8" )
112+ config .username , config .password = values .split (":" )
113+
114+ if config .debug :
115+ click .echo ("Username and password config values set" )
119116
120117 # Important! Some of the attributes set above (e.g. error_retry_max) are not
121118 # present in the cloudsmith_api.Configuration class declaration.
0 commit comments