5

In order to set up keyring authentication to a private pip repository, I followed the steps on Setting up authentication to Python package repositories - Authenticating with keyring.

I chose to use an environment variable for the authentication. I verified it was set correctly:

abc@def:~/PycharmProjects/ghi$ echo $GOOGLE_APPLICATION_CREDENTIALS
/home/jkl/.googlekeys/serviceaccount.json

I also logged in my user using gcloud auth login. The user that is logged in is the owner of a service account that has write permission on the Artifact Registry.

Unfortunately, I get the following output when trying to install a package:

abc@def:~/PycharmProjects/ghi$ pip install stringcase
Looking in indexes: https://pypi.org/simple, https://us-west1-python.pkg.dev/mno-415182/pqr/simple/
User for us-west1-python.pkg.dev:

I expected the keyring to handle the authentication at this step. Any suggestions for determining the cause of this problem?

Stéphane
  • 105
  • 1
  • 9
  • 1
    Did you follow both the `Keyring authentication with user credentials` and `Keyring authentication with service account credentials` steps of the documentation? If so, this might be the problem, as they are both different methods of the final step in the authentication, the documentation can be a bit misleading on this. So try undoing the `gcloud auth login` and let me know if it works. – Ralemos Aug 30 '21 at 12:53
  • @RafaelLemos Thank you! I did indeed follow both of these steps, but after issuing `gcloud auth revoke`, the problem still persists. – Stéphane Aug 30 '21 at 13:05
  • @RafaelLemos Actually, I did get a bit further after revoking everything with `gcloud auth revoke --all`: it now installs packages using pip from PyPI without prompting for credentials, so maybe authentication goes well! Ultimately, I wanted to publish a package using Poetry, and that still fails (it does still prompt for credentials there). I think I should pose that question in a separate thread as it may be a Poetry issue. – Stéphane Aug 30 '21 at 13:18
  • So, at the end the issue was fixed? I would say that is indeed better to create a separate question for the Poetry issue, as it's a separate topic altogether. – Ralemos Aug 31 '21 at 12:26
  • @RafaelLemos Yes, I think this is fixed. I was able to install a package with pip and will create a separate question for Poetry. Thank you very much! – Stéphane Aug 31 '21 at 12:29
  • Great, I will add this into an answer then, thanks for letting me know :) – Ralemos Aug 31 '21 at 12:32
  • I have the same problem. I only followed the "with user credentials" step and I'm still being asked for a username and password. I went through the doc like 3 times now. I use an M1 Macbook Pro. – papaiatis Oct 28 '22 at 12:13

1 Answers1

1

As per our discussion in the comments, the problem is that you followed both the Keyring authentication with user credentials and Keyring authentication with service account credentials steps of the documentation. Those are both different methods of doing the final step in the authentication process.

To fix it all you need to do it is revoke the authentication with gcloud auth revoke --all and it will work.

Ralemos
  • 5,571
  • 2
  • 9
  • 18