Search code examples
google-cloud-platformgoogle-authenticationgoogle-artifact-registry

Keyring authentication to Artifact Repository not working (GCP)


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?


Solution

  • 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.