@@ -125,19 +125,19 @@ def __init__(self, factory: AuthFactory, *args: Any, **kwargs: Any) -> None:
125
125
126
126
def received_headers (self , headers : Dict [str , Any ]) -> None :
127
127
auth_header : str = headers .get ("Authorization" , None )
128
- if auth_header is not None :
129
- [auth_type , token ] = auth_header .split (" " , 1 )
130
- if auth_type == "Bearer" :
131
- self ._factory .set_token (token )
128
+ if not auth_header :
129
+ return
130
+ [auth_type , token ] = auth_header .split (" " , 1 )
131
+ if auth_type == "Bearer" :
132
+ self ._factory .set_token (token )
132
133
133
134
def sending_headers (self ) -> Dict [str , str ]:
134
135
token = self ._factory .token ()
135
- if token is None :
136
+ if not token :
136
137
username , password = self ._factory .auth
137
- auth_token = "{0 }:{1}" . format ( username , password )
138
+ auth_token = f" { username } :{ password } "
138
139
auth_token = "Basic " + base64 .b64encode (auth_token .encode ("utf-8" )).decode ("ASCII" )
139
140
# There seems to be a bug, `authorization` must be lower key
140
141
return {"authorization" : auth_token }
141
142
else :
142
- # # There seems to be a bug, `authorization` must be lower key
143
143
return {"authorization" : "Bearer " + token }
0 commit comments