-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication from poetry.toml doesn't work on 1.1.x #3216
Comments
I'm also experiencing this same issue |
Not relevant to the issue, but note that the @jairhenrique for sanity,
Also, just realised, you store credentials in your poetry config http-basic.MyPrivateFeed user pass |
I just ran |
Environment variables, pre-existing configuration files (
https://python-poetry.org/docs/repositories/#configuring-credentials This will either store the credentials in your system keyring or to a file at |
First test
Second test
|
A temporary solution that works for me is adding the private repository via
|
I had the same issue, it works for me when I do the following steps:
|
Another data point: I could not get @ayalganem55's steps to work. But what seemed to do the trick was to set In
Local configuration: |
@abn I execute The process to build config merge this config with my |
@jairhenrique : I see this is closed. However, I am unclear on the conclusion. I am seeing this on poetry 1.1.6. I don't see any linked PR's or anything in the comments to indicate resolution. Can you help point me in the right direction? |
By the way, in my case the repo should not even be requiring authorization. I can reach it with curl just fine without any auth. I need auth to publish to it but not to pull. The poetry config really shouldn't even be used in this case. |
I'm using Azure's private artifact servers. I managed to publish without any problem, but when I use the poetry install or poetry add commands, I can't restore or add any package from my private repository. I am really enjoying using poetry and this has been the only barrier I have encountered so far. note: I tried to configure the poetry config as suggested here #3344 I also ran the .py script that does the authentication and already sets up the poetry, but nothing worked. The message I always get is: poetry install Because teste-mb27 depends on teste-mb26 (0.0.1.dev0) which doesn't match any versions, version solving failed. poetry add Could not find a matching version of package teste-mb26 can you help me? am I setting up something wrong?
|
Well, this issue is closed, but I found my issue which I think may actually be different. I had http-basic setup for the repository for the purpose of posting to it. For our artifactory pypi repository authorization is not needed to get from the repository, only to publish. Therefore, it did not even occur to me that poetry may be using the basic auth credentials for get operations. However, I changed my password so auth failed even for get. I guess that kind of makes sense because poetry doesn't know how the security is configured on your repo so if you provide a user name and password it just uses it for all operations. Your user name and password should be valid. It just took me longer to troubleshoot because the particular operation I was performing did not actually require authorization so I forgot to check if the credentials themselves are valid. I guess @marcosborges we both solved our respective problems. However, maybe this will help the next person. |
I have a similar issue, I'm using the following configuration in [[tool.poetry.source]]
name = "privateRepo"
url = "https://__token__:[email protected]/api/v4/projects/1234567/packages/pypi/simple" Everything works fine on my machine, but on gitlab I get the following error: Command ['/root/.cache/pypoetry/virtualenvs/xxxxx-py3.9/bin/pip', 'install', '--no-deps', '--index-url',
'https://__token__:AXXXXXXA@__token__:[email protected]/api/v4/projects/1234567/packages/pypi/simple',
'package-name==0.2.2']
errored with the following return code 1, and output:
Looking in indexes: https://__token__:[email protected]/api/v4/projects/1234567/packages/pypi/simple
WARNING: 401 Error, Credentials not correct for https://__token__:[email protected]/api/v4/projects/1234567/packages/pypi/simple/package-name/ I noticed that the url includes |
Running into this issue, this time in a docker build.
Inside the container, I get the error
Notice that is
The
Outside, I have no problem doing
To set up my local env, I ran:
which generates config:
I'm doing the same exact thing in the container, no dice. I even tried copying in the plaintext password into
In fact I even tried copying the exact files I'm using locally, into the docker container. Still failing. However, it looks like I can run this sequence:
This works great until I go to actually install the local package with Notice that in the
"Full" trace btw (I don't get a full traceback, even with -vvv):
|
In exceutor.py Or, alternatively, a Link object should have it's own Authenticator instance. Or, the |
This seems to fix the problem with embedded URLs not getting the correct credentials: def find_links_for_package(self, package: Package) -> List[Link]:
page = self._get("/{}/".format(package.name.replace(".", "-")))
if page is None:
return []
links = list(page.links_for_version(package.version))
for link in links:
if link.netloc in self._authenticator._credentials:
url = list(urllib.parse.urlsplit(link.url))
username, password = self._authenticator._credentials[link.netloc]
url[1] = f'{username}:{password}@{link.netloc}' # [1] is netloc
link.url = urllib.parse.urlunsplit(url)
return links |
Why this issue is closed? It seems like the fix has not been pushed |
After trying out everything stated here multiple times without avail and banging my head against the wall over the course of a few days, I finally seem to have a situation working where a poetry project can import a self-made private package published with poetry. While looking at the
Apparently, the password is set in your OS's native keychain by the library called
Poetry's
...and after running This worked with
|
I also dont understand why this ticket was closed. I had exactly the same problem... In fact, because of this Keyring issue, when installing the public packages, poetry even starts looking first for my private repo, so I started specifying in each dependency, the repo source: [tool.poetry.dependencies]
python = "^3.9"
asyncio-mqtt = "^0.11.0"
environs = "^9.3.5"
mqtt-api = { version = "^0.5.0", source = "pypi-private"}
[tool.poetry.dev-dependencies]
pytest = { version = "^6.2.5", source = "pypi"}
pytest-lazy-fixture = { version ="^0.6.3", source = "pypi"}
... And just after this process, the library tells me the problem is really with the authentication with the private server. After following the steps provided by @SimonVerhoek everything worked as expected. [[tool.poetry.source]]
name = "pypi-private"
url = "https://username@password:pypi-private.com/simple/"
default = false
secondary = true it also works, but this is not ideal as no one wants the credentials to be plain text in github. Another fun fact: I didnt experience this problem neither in MacOS or Docker container. Was really only when I tried in a Linux virtual machine :/ |
I am experiencing the same issue with GCP artifact registry, even after trying all the aforementioned alternative, I've also tried version |
Thank you @SimonVerhoek , your steps helped me solve this problem when trying to download packages from AWS CodeArtifact. We are building container images and using Docker secrets to mount the I opted to configure the Python keyring with environment variables in our build scripts like this:
|
We have this same issue with a private gitlab package registry. When fully specifying the URL including token, it works: [[tool.poetry.source]]
name = "<repo-name>"
url = "https://__token__:<TOKEN>@gitlab.com/api/v4/projects/<project_id>/packages/pypi/simple" However, we don't want to hardcode credentials of course, but specify them using Edit: what I wrote here before was not true, I could not find a way to fix it using both the There seem to be some fixes, I tried to upgrade poetry using |
I had this issue recently with AWS CodeArtifact and what solved my problem was using these environment variables: |
With recent changes the use cases with azure (keyring auth), gitlab (path based auth) etc should be significantly improved. There was also a bug in how the the See these issues for more information: #5563 #5518 #4086 Install Poetry from VCSpipx install --force --suffix=@git 'poetry @ git+https://github.com/python-poetry/poetry.git' |
I've got the same issues with a private repo as mentioned above. Upgraded to version 1.2.0b2.dev0 with @abn's suggestion, but I'm faced with the same issue albeit with a slightly different output
|
@kaybee99 how was auth configured? |
Username added to auth.toml with @The-Fonz suggestion does work however I'm keen to avoid commiting credentials wherever possible. |
@kaybee99 you will need |
Doesn't work either unfortunately. Same error |
@kaybee99 unfortunately I can't do much here as I can't reproduce this with my setup. You can find me on discord and we could maybe debug it together. Alternatively, you can consider adding some additional logs in authenticator and password manager to see what's going on. |
Thanks, I appreciate it. I've already spent way too much time trying to get this working so I'm going to stick with the credentials in URL workaround for now as it's only affecting my environment and works fine in our pipeline. Just got to remember to not push those changes! |
Closing for now as there are significant improvements in auth, and everything here is working as expected for me on 1.2.x. If you're having trouble passing credentials, I'd suggest first opening a Discussion or joining Discord to get some troubleshooting help. If you've done extensive troubleshooting and are sure there's a Poetry bug, please open a new issue. |
@neersighted I think it is still very unstable/opaque, I get auth errors every now and then (and I'm not even talking about CI/CD pipelines). There are multiple ways doing this which make it unclear for us how to search the root cause of the issue. In my opinion, if a local token is hard coded in So maybe people maintaining poetry have no idea what is going on and its perfectly fine, but closing the issue wont help solving it. Maybe its a network error, maybe its not a bug in poetry but somewhere else, but since we have no clue I think its still an issue. For example today I upgraded from py3.10 to 3.11 and got the HTTP 401 error. I tried many random things, and found one that fixed the issue (but I have no idea why), I removed the token from the repo URL (which in the past was probably a fix I made to fix the exact same issue): [[tool.poetry.source]]
name = "myrepo"
+url = "https://gitlab.com/api/v4/projects/xxxxxxxx/packages/pypi/simple"
-url = "https://__token__:[email protected]/api/v4/projects/xxxxxxxx/packages/pypi/simple"
secondary = true I'm pretty sure I'll come back to this issue in 6 months only to find out that I made that removal and that it now causes a problem somewhere else (pipeline for example). I would love to know a solution that is stable over time. |
I am facing authentication issues with a private repo that doesn't require authentication. any guidance on how to solve this? |
After spending multiple hours trying the different solutions, for me the solution was changing the password to something that didn't have special characters and thus didn't need to be percent encoded. The current password i was using worked perfectly with other Pypi installation using pip, but didn't work here neither in the escaped or the not escaped version https://pip.pypa.io/en/stable/topics/authentication/#percent-encoding-special-characters |
Upgrade from poetry 1.1.13 to 1.5.1 seemed to resolve for me |
I had this issue on a Mac, poetry having been installed with homebrew. tl;dr what worked was:
I had tried using
I also tried setting the credentials by exporting Following some comments above I ran with
Ah!! So it's trying to read a config file at |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am on the latest Poetry version.
I have searched the issues of this repo and believe that this is not a duplicate.
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).OS version and name: MacOS 10.15.7
Poetry version: 1.1.3
Issue
After upgrade from 1.0.10 to 1.1.3 the authentication for private repositories doesn't work.
I have an file
poetry.toml
with this content:And on
pyproject.toml
When I try to update/lock/install I get an error:
update
lock
The text was updated successfully, but these errors were encountered: