Skip to content

Authenticate Twine to Google Artifact Registry


If you work at a company that uses python, there is a high chance that you need to store python packages in a private registry


In order to authenticate to GAR with Twine, we need to do the below

Install Keyring

pip3 install keyring
pip install keyring

Install the Artifact Registry Backend

pip3 install
pip install

Get the config for your repo

gcloud artifacts print-settings python \
    --project=<your project goes here> \
    --repository=<repository name goes here> \
    --location=<location goes here>

Which will give you something like the below

# Insert the following snippet into your .pypirc

index-servers =


# Insert the following snippet into your pip.conf

extra-index-url =<project>/<repo>/simple/

Setup your files

The next steps will have you editing files


index-servers =
    < repo name>

repository =<project>/<repo>

Pip config

There are multiple locations for this file

You should run pip config debug and note the files that exist

Tip: look for exists: True

Using the file that exists, or the one you use, insert the below in to it

extra-index-url =<project>/<repo>/simple/

Gcloud auth for good measures

gcloud auth login

Want to make this site better? Open a PR or help fund hosting costs