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

WIP: Fix - Cannot access private repository using token #6795

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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/6795.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow access to an index using a URL embedded token
10 changes: 5 additions & 5 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _get_new_credentials(self, original_url, allow_netrc=True,
logger.debug("Found credentials in keyring for %s", netloc)
return kr_auth

return None, None
return username, password

def _get_url_and_credentials(self, original_url):
"""Return the credentials to use for the provided URL.
Expand All @@ -314,11 +314,11 @@ def _get_url_and_credentials(self, original_url):

# If nothing cached, acquire new credentials without prompting
# the user (e.g. from netrc, keyring, or similar).
if username is None or password is None:
if username is None and password is None:
username, password = self._get_new_credentials(original_url)

if username is not None and password is not None:
# Store the username and password
if username is not None or password is not None:
# Store any acquired credentials
self.passwords[netloc] = (username, password)

return url, username, password
Expand All @@ -330,7 +330,7 @@ def __call__(self, req):
# Set the url of the request to the url without any credentials
req.url = url

if username is not None and password is not None:
if username is not None or password is not None:
booleand marked this conversation as resolved.
Show resolved Hide resolved
# Send the basic auth with this request
req = HTTPBasicAuth(username, password)(req)

Expand Down