pip icon indicating copy to clipboard operation
pip copied to clipboard

pip still prompts for username/password even when keyring is configured

Open Time0o opened this issue 1 year ago • 3 comments

Description

I'm trying to download a package from a GitLab registry using credentials stored via keyring. I believe I am following the documentation but pip neither uses the keyring credentials nor displays an error and instead just prompts for username/password.

$ which pip
/home/timo/python_venvs/my_venv/bin/pip
$ which keyring
/home/timo/python_venvs/my_venv/bin/keyring
$ echo <MY_TOKEN> | keyring set https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_TOKEN_NAME>
$ pip install --keyring-provider import -i https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_PACKAGE>
User for gitlab.com:
...

Expected behavior

pip uses the credentials stored in keyring.

pip version

24.0

Python version

3.10.12

OS

Ubuntu 22.04.4 LTS

How to Reproduce

  1. Install pip and keyring
  2. Create a GitLab package registry and upload a Python package to it
  3. Create a GitLab access token with read_api rights
  4. Store the token via keyring
  5. Run pip install --keyring-provider import -i https://gitlab.com/api/v4/groups/<MY_GROUP_ID>/-/packages/pypi/simple <MY_PACKAGE>

Output

No response

Code of Conduct

Time0o avatar Apr 29 '24 09:04 Time0o

Edit: nevermind, I was wrong: @Time0o is using --keyring-provider import, not subprocess.

~@Time0o, this looks likely to be a duplicate of https://github.com/pypa/pip/issues/12543. When using keyring as a subprocess, it can't discover the username. Workarounds are to either change your index url to include a username, or use keyring with the import provider, which does have support for keyring's get_credentials functionality to fetch both a password and a username.~

jfly avatar Jun 05 '24 17:06 jfly

@Time0o, this looks likely to be a duplicate of #12543. When using keyring as a subprocess, it can't discover the username. Workarounds are to either change your index url to include a username, or use keyring with the import provider, which does have support for keyring's get_credentials functionality to fetch both a password and a username.

The reproducer includes --keyring-provider import, so I don't think your PR is relevant.

Darsstar avatar Jun 05 '24 18:06 Darsstar