@@ -139,7 +139,7 @@ def get_auth_token(
139
139
response, and MUST include the www-authenticate header
140
140
141
141
Args:
142
- res (Type[ requests.Response] ): The response from the registry API
142
+ res (requests.Response): The response from the registry API
143
143
reg_auth (str): The auth retrieved for the registry
144
144
145
145
Returns:
@@ -168,9 +168,11 @@ def get_auth_token(
168
168
169
169
# Send the request to the auth service, parse the token from the
170
170
# response
171
- headers = {
172
- 'Authorization' : f"Basic { reg_auth } "
173
- }
171
+ headers = {}
172
+ if len (reg_auth ) > 0 :
173
+ headers = {
174
+ 'Authorization' : f"Basic { reg_auth } "
175
+ }
174
176
token_res = requests .get (auth_url , headers = headers )
175
177
token_res .raise_for_status ()
176
178
token_json = token_res .json ()
@@ -219,7 +221,7 @@ def query_blob(
219
221
# Send the request to the distribution registry API
220
222
# If it fails with a 401 response code and auth given, do OAuth dance
221
223
res = requests .get (api_url , headers = headers )
222
- if res .status_code == 401 and found and \
224
+ if res .status_code == 401 and \
223
225
'www-authenticate' in res .headers .keys ():
224
226
# Do Oauth dance if basic auth fails
225
227
# Ref: https://distribution.github.io/distribution/spec/auth/token/
@@ -308,7 +310,7 @@ def query_manifest(
308
310
# Send the request to the distribution registry API
309
311
# If it fails with a 401 response code and auth given, do OAuth dance
310
312
res = requests .get (api_url , headers = headers )
311
- if res .status_code == 401 and found and \
313
+ if res .status_code == 401 and \
312
314
'www-authenticate' in res .headers .keys ():
313
315
# Do Oauth dance if basic auth fails
314
316
# Ref: https://distribution.github.io/distribution/spec/auth/token/
@@ -433,7 +435,7 @@ def delete(
433
435
# Send the request to the distribution registry API
434
436
# If it fails with a 401 response code and auth given, do OAuth dance
435
437
res = requests .delete (api_url , headers = headers )
436
- if res .status_code == 401 and found and \
438
+ if res .status_code == 401 and \
437
439
'www-authenticate' in res .headers .keys ():
438
440
# Do Oauth dance if basic auth fails
439
441
# Ref: https://distribution.github.io/distribution/spec/auth/token/
0 commit comments