Poetry Authorization error accessing private repository (tested)
Authorization error accessing means the private index answered 401. Set credentials for that source: poetry config http-basic.<source> <user> <password-or-token>, or POETRY_HTTP_BASIC_<SOURCE>_USERNAME / _PASSWORD in CI.
Setup used in every transcript: a project made with poetry init -n and poetry source add --priority=primary corp https://localhost:8963/simple/. The index at localhost:8963 requires HTTP Basic auth (user alice, password s3cret, test values) and answers 401 otherwise, like a private Artifactory, Nexus or GitLab registry. Its CA is trusted with certificates.corp.cert (see Poetry SSL errors). Measured with Poetry 2.5.1 on Python 3.13.5 (Linux), fresh config per run.
1. The error: Authorization error accessing
Transcript:
$ poetry config certificates.corp.cert /tmp/us397/ca2.pem
$ poetry add six
Creating virtualenv demo in /tmp/pow397/.venv
Source (corp): Authorization error accessing https://localhost:8963/simple/six/
Could not find a matching version of package six
[exit 1]
Without credentials the server returned 401 and Poetry printed Source (corp): Authorization error accessing https://localhost:8963/simple/six/, then the misleading Could not find a matching version of package six. The package exists; Poetry just could not read the index.
2. Fix: poetry config http-basic.<source>
Transcript:
$ poetry config certificates.corp.cert /tmp/us397/ca2.pem
$ poetry config http-basic.corp alice s3cret
Using a plaintext file to store credentials
$ poetry add six
Using version ^1.17.0 for six
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
- Installing six (1.17.0)
Writing lock file
Creating virtualenv demo in /tmp/pow397/.venv
poetry config http-basic.corp alice s3cret stores credentials for the source named corp. The name must match poetry source add exactly. With no system keyring available Poetry printed Using a plaintext file to store credentials and wrote them to auth.toml in its config directory; on a desktop with a keyring the password goes there instead. For token-based registries, use the username your registry documents and the token as the password.
3. CI: environment variables (and a wrong password)
Transcript:
$ poetry config certificates.corp.cert /tmp/us397/ca2.pem
$ poetry add six
Using version ^1.17.0 for six
Updating dependencies
Resolving dependencies...
Package operations: 1 install, 0 updates, 0 removals
- Installing six (1.17.0)
Writing lock file
Creating virtualenv demo in /tmp/pow397/.venv
POETRY_HTTP_BASIC_CORP_USERNAME and POETRY_HTTP_BASIC_CORP_PASSWORD (source name upper-cased) work without touching any config file, which suits CI secrets. With a wrong password the output is exactly the same Authorization error accessing as with no credentials:
Transcript:
$ poetry config certificates.corp.cert /tmp/us397/ca2.pem
$ poetry add six
Creating virtualenv demo in /tmp/pow397/.venv
Source (corp): Authorization error accessing https://localhost:8963/simple/six/
Could not find a matching version of package six
[exit 1]
So the message does not tell you whether the credentials are missing, wrong, or set under a different source name. Check poetry config --list for the source name and test the URL with the same user and token, e.g. curl -u user:token https://host/simple/<package>/; a 401 there means the token itself is wrong or lacks read permission.
Related: Poetry ignore SSL errors, uv pip install vs uv add, pip error: externally-managed-environment.
Frequently asked questions
What does Poetry Authorization error accessing mean?
The source returned 401 Unauthorized: credentials are missing, wrong, or stored under a different source name. Poetry prints the same message in all three cases.
How do I add credentials for a private Poetry source?
poetry config http-basic.<source> <user> <password>, with <source> matching poetry source add.
How do I pass Poetry repository credentials in CI?
Set POETRY_HTTP_BASIC_<SOURCE>_USERNAME and POETRY_HTTP_BASIC_<SOURCE>_PASSWORD, with the source name upper-cased.
Written with AI assistance. Measured on 2026-10-23 with Poetry 2.5.1 on Python 3.13.5 (Linux) against a local HTTPS package index requiring Basic auth (test credentials). Each transcript was produced by running the commands verbatim. PlainHeaders is our extension; Poetry is free.