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

Add support for getting username from keyring #637

Open
lordmauve opened this issue Apr 14, 2023 · 3 comments
Open

Add support for getting username from keyring #637

lordmauve opened this issue Apr 14, 2023 · 3 comments

Comments

@lordmauve
Copy link

lordmauve commented Apr 14, 2023

Flit uses keyring.get_password() to load a password for authentication to the package index.

However, keyring also provides an API to get a username also, keyring.get_credential().

Twine already has support for this and will not prompt for a username if get_credential() returns a credential. However flit always prompts if the username is not set in .pypirc.

This is particularly useful where the username is not particularly meaningful and therefore should not be typed by the user - for example, Google Artifact Registry has a keyring plugin that returns a username of oauth2token where the OAuth token is the password.

@takluyver
Copy link
Member

Thanks, I think this makes sense. I also want to add support for per-project tokens, which might mean looking them up using the project name as part of the 'username'. So we might need to take some care over what order different possibilities are tried.

@z3dev
Copy link

z3dev commented Feb 1, 2024

@takluyver This enhancement is probably required now, especially when using keyring with the Google keyring provider. There's really no way to authenticate without some fixes.

I was able to use twine to publish to Google Artifactory. Here's the pypirc.

[distutils]
index-servers =
    hi-int-prd-shared-applications

[hi-int-prd-shared-windows-applications]
repository = https://us-central1-python.pkg.dev/hi-internal-prod-b0da/hi-int-prd-shared-applications/

[global]
index-url = https://us-central1-python.pkg.dev/hi-something-9999/hi-int-prd-shared-applications/simple/

As you can see, twine does not expect username or password in the configuration.

@z3dev
Copy link

z3dev commented Feb 1, 2024

And here's a link to the Google documentation on publishing python packages to Artifact Registry.

https://cloud.google.com/artifact-registry/docs/python/manage-packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants