One of the improvements we did to Charmcraft in the last few months (well, actually to the Craft Store library which is used by Charmcraft) is to securely store the credentials obtained from the user’s login to Charmhub in a keyring in the user’s machine.
But sometimes Charmcraft fails to find a keyring in the user’s environment. The environment may not have a keyring, or it may not be accessible from the snap in which Charmcraft runs.
One simple workaround for this is to install the gnome-keyring package. It’s recommended even in non-GNOME environments (the name is misleading, it’s a simple package and will not bring a zillion dependencies).
All that said, generally there are no keyrings by default in CI/CD or other remote systems; for Charmcraft to work in those environments the user should login in their machine and export the credentials, and then use them in the remote system, as is explained in this forum post.
Please comment on this post with your experience, issues, problems and how/if you solved them. Thanks!
It’s a little bit of a headache to get the keyring unlocked from the CLI, though. I found a hacky script that prompts for the current user’s password, then restarts the daemon. It didn’t feel super great to do things that way, though. How are you unlocking the keyring from the CLI?
but since I am in multipass instance, it cannot open a browser. But charmcratft provides a link, and copying it to browser on a host machine solve auth issue.
@facundognome-keyring being installed no longer resolves this problem for me with charmcraft. I had it installed and still had issues. I tried @beliaev-maksim’s workaround without success. Nor did uninstalling and reinstalling gnome-keyring help.
I’m using charmcraft 2.2.0 and ubuntu server 22.04.
<----------------------------------------------------->
To log in to Charmhub, run:
charmcraft login --export ~/secrets.auth
This should output:
Opening an authorization web page in your browser.
If it does not open, please open this URL:
https://api.jujucharms.com/identity/login?did=48d45d919ca2b897a81470dc5e98b1a3e1e0b521b2fbcd2e8dfd414fd0e3fa96
As we are inside a Multipass instance, this will not open the authorization web page directly. Copy-paste the provided web link into your web browser instead. Use your Ubuntu SSO to log in.
When you’re done, you should see in your terminal the following:
Login successful. Credentials exported to '~/secrets.auth'.
Now set an environment variable with the new token: