Skip to content
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

Fail to authenticate for Azure Artifacts #2760

Closed
westr029 opened this issue Apr 2, 2024 · 3 comments · Fixed by #2854
Closed

Fail to authenticate for Azure Artifacts #2760

westr029 opened this issue Apr 2, 2024 · 3 comments · Fixed by #2854
Labels
🐛 bug Something isn't working

Comments

@westr029
Copy link

westr029 commented Apr 2, 2024

Steps to reproduce

To add a private pypi from Azure Artifacts, I added a section in the pyproject.toml as follows:

[[tool.pdm.source]]
name = "datahub"
url = "https://pkgs.dev.azure.com/xxx/Datahub/_packaging/Datahub/pypi/simple/"
verify_ssl = true

I try to add a package to the pyproject.toml that is available in the private repo by:
pdm add datahub-cli==0.2.0a6 -v

Actual behavior

When I run the above command, I get the message below:

Adding packages to default dependencies: datahub-cli==0.2.0a6
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   datahub-cli==0.2.0a6
pdm.termui:   python==3.12.*
pdm.termui:   Adding requirement datahub-cli==0.2.0a6
unearth.collector: Failed to collect links from https://pypi.org/simple/datahub-cli/: Client Error(404): Not Found

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=5.2.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
   at NuGetCredentialProvider.Program.<Main>d__3.MoveNext()
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start[TStateMachine](TStateMachine& stateMachine)
   at NuGetCredentialProvider.Program.Main(String[] args)
   at NuGetCredentialProvider.Program.<Main>(String[] args)
unearth.auth: Keyring is skipped due to an exception: Failed to get credentials: process with PID 24148 exited with code 3762504530; additional error message: 
User for pkgs.dev.azure.com:

However, when I pass personal login information via the pyproject.toml in the tool.pdm.source section (which I don't want), it does work.

The same error also appears, when I want to install a package from a public pypi, which is very inconvenient.

Expected behavior

Package from private pypi is added to pyproject.toml and installed.

Environment Information

pdm info; pdm info --env :

PDM version:
  2.13.2
Python Interpreter:
  C:\Users\avanwestreenen\OneDrive - Waterschap Vallei Veluwe\Projects\PlayGround2\.venv\Scripts\python.exe (3.12)
Project Root:
  C:/Users/avanwestreenen/OneDrive - Waterschap Vallei Veluwe/Projects/PlayGround2
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.12.2",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "11",
  "platform_system": "Windows",
  "platform_version": "10.0.22631",
  "python_full_version": "3.12.2",
  "platform_python_implementation": "CPython",
  "python_version": "3.12",
  "sys_platform": "win32"
}
@westr029 westr029 added the 🐛 bug Something isn't working label Apr 2, 2024
@frostming
Copy link
Collaborator

frostming commented Apr 3, 2024

There seems to be some issue with the keyring that can't be fixed on PDM side, you can check it by running keyring directly:

import keyring
keyring.get_credential(url, username)
keyring.get_password(url, username)

However, when I pass personal login information via the pyproject.toml in the tool.pdm.source section (which I don't want), it does work.

You can also set it in config:

pdm config pypi.datahub.username "xxxx"
pdm config pypi.datahub.password "xxxxx"

@westr029
Copy link
Author

westr029 commented Apr 4, 2024

There seems to be some issue with the keyring that can't be fixed on PDM side, you can check it by running keyring directly:

import keyring
keyring.get_credential(url, username)
keyring.get_password(url, username)

Hmm, using this keyring-only example, I do not get any errors. Would you expect this example raises a similar error as with pdm?

You can also set it in config:

pdm config pypi.datahub.username "xxxx"
pdm config pypi.datahub.password "xxxxx"

Sure, good point. Can indeed use this as a workaround.

@Pluttodk
Copy link
Contributor

I have manage to get all authentication to work with azure artifacts by running the following:

pdm self add keyring artifacts-keyring

And then simply add [[tool.pdm.source]] as you did above with the url= for your artifacts feed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants