Using Artifactory (https://cloud.google.com/artifact-registry) I intend to add a dependency with poetry (https://python-poetry.org/docs/repositories/).
I can install with command: pip install --index-url https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/ <PACKAGE_NAME>
(auth using keyrings.google-artifactregistry-auth)
I intend to use POETRY to manage my dependencies. I don't know if using poetry adds this dependence. With poetry add --source <PACKAGE_NAME> https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>
I'm getting this error:
poetry update
Updating dependencies
Resolving dependencies... (0.9s)
RepositoryError
401 Client Error: Unauthorized for url: https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/pytest/
My pyproject.toml
...
[[tool.poetry.source]]
name = "SOME_LIB"
url = " https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/"
secondary = true
Here there is details how to config with PIP/VIRTUALENV: https://cloud.google.com/artifact-registry/docs/python/authentication but not have details about Poetry.
Do you have any tips about it?
Your RepositoryError
of
401 Client Error: Unauthorized for url: https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/pytest/
clearly indicates that you lack authorization for the URL mentioned. So you will need to make sure you properly get and use the authorization, that is, you will have a user with credentials who actually has the right to access it.
Once you have that, you will need to authenticate, so the server you are sending the request to will be able to determine who you are and therefore to grant you proper access. Read: https://python-poetry.org/docs/repositories/#configuring-credentials
The page provides the
poetry config http-basic.foo <username> <password>
example, explaining that you can set up some credentials for a specific repository. You can specify only the username, but then whenever you try to access the URL, you will be prompted for the password.
You can also publish by adding --username
and --password
to the command. You can also specify environment variables, like
export POETRY_PYPI_TOKEN_PYPI=my-token
export POETRY_HTTP_BASIC_PYPI_USERNAME=<username>
export POETRY_HTTP_BASIC_PYPI_PASSWORD=<password>
See https://python-poetry.org/docs/configuration/#using-environment-variables
Anyways, the error tells you that you were not properly authenticated via the credentials that are needed, so either you do not have credentials, they are incorrect or you lack privilege.