Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Requiring keyring authentication when repository returns 403 #9871

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/9870.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This fixes a keyring auth issue when internal pip repos return 403 rather than 401
6 changes: 3 additions & 3 deletions src/pip/_internal/network/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def __call__(self, req):
# Send the basic auth with this request
req = HTTPBasicAuth(username, password)(req)

# Attach a hook to handle 401 responses
# Attach a hook to handle 401, 403 responses
req.register_hook("response", self.handle_401)

return req
Expand All @@ -236,9 +236,9 @@ def _should_save_password_to_keyring(self):

def handle_401(self, resp, **kwargs):
# type: (Response, **Any) -> Response
# We only care about 401 responses, anything else we want to just
# We only care about 401 and 403 responses, anything else we want to just
# pass through the actual response
if resp.status_code != 401:
if resp.status_code not in [401, 403]:
return resp

# We are not able to prompt the user so simply return the response
Expand Down