Open rcpeene opened 5 months ago
@jwodder - do you have any suggestions for @rcpeene ? or what to delete to rest the keyring?
@rcpeene Could you show the (non-exception) output from the script when run, particularly the part that asks you for a password etc.?
Even when providing my dandi api key, I get a prompt to enter a keyring password.
How are you providing the API key?
@rcpeene, I have run into this myself, and because I don't really use my system keyring, I end up doing something like:
$ export DANDI_API_KEY=<paste in API key here>
and then the CLI will no longer prompt for passwords etc. Just be careful about who can see your screen etc., as you want to protect that key from unauthorized use by others.
jwodder may have a more comprehensive solution but exporting your key to your shell should get you unstuck.
@jwodder I apologize, I left this out of the snippet
client = dandiapi.DandiAPIClient(token=dandi_api_key)
dandiset = client.get_dandiset(dandiset_id)
Here is the keyring prompt:
@rcpeene The download()
function uses its own client instance, so doing client = dandiapi.DandiAPIClient(token=dandi_api_key)
has no effect on it. As @waxlamp said, setting the API key via an environment variable may be the simplest way to pass it to download()
.
It seems you previously stored your API key in an encrypted keyring file on the system. You can remove this keyfile and start over by deleting ~/.local/share/python_keyring/crypted_pass.cfg
. See the handbook for more information on how dandi uses keyrings.
This makes sense. On my local machine I already have the DANDI_API_KEY defined which is probably why I didn't have the problem.
I still don't understand why entering my dandi api key into the keyring prompt returns 'incorrect password' though
I still don't understand why entering my dandi api key into the keyring prompt returns 'incorrect password' though
If you mean the "Please enter password for encrypted keyring" prompt, that's because it's not asking you for your API key. Encrypted keyfiles are well, encrypted, and that encryption involves a user-defined password that would have been set when you first created the keyfile, so now it's asking you for the password used to encrypt the keyfile so it can decrypt the file and retrieve the API key stored within.
I've encountered this problem again. On dandihub, I have set DANDI_API_KEY as an environment variable and deleted the file at ~/.local/share/python_keyring/crypted_pass.cfg
. Still getting the keyring prompt.
When I try on google colab, I instead get the following prompts:
Please provide API Key for dandi: ** Please set a password for your new keyring:
Seems like keyring is being setup automatically?
Hi @jwodder, I am able to reproduce this issue for an embargoed Dandiset on JupyterHub. I am not sure why I am being prompted for the API key since it is declared in the DANDI_API_KEY
environment variable. It only occurs when running the following commands in a Jupyter Notebook on DandiHub, but not when using the terminal in DandiHub. Any suggestions would be appreciated. Thank you.
I removed the keyfile at ~/.local/share/python_keyring/crypted_pass.cfg
.
In a Jupyter notebook on DandiHub, using the CLI:
Commands
!export DANDI_API_KEY=<dandi_api_key>
!dandi download https://api.dandiarchive.org/api/assets/9a4b64df-433c-4efe-a1e7-2ae55b3f95ac/download/
Returns
Please provide API Key for dandi:
In a Jupyter notebook on DandiHub, using the Python API: Commands
!export DANDI_API_KEY=<dandi_api_key>
from dandi.download import download
download('https://api.dandiarchive.org/api/assets/9a4b64df-433c-4efe-a1e7-2ae55b3f95ac/download/','.')
Returns
Please provide API Key for dandi: <dandi_api_key>
Please set a password for your new keyring: ········
Please confirm the password:
Just to dismiss some confusion, @kabilar you are running
!export DANDI_API_KEY=<dandi_api_key>
!dandi download https://api.dandiarchive.org/api/assets/9a4b64df-433c-4efe-a1e7-2ae55b3f95ac/download/
in two different cells? then I guess sessions are not shared etc, so effect of export
would be lost for the next command.
Try smth like
!DANDI_API_KEY=<dandi_api_key> dandi download https://api.dandiarchive.org/api/assets/9a4b64df-433c-4efe-a1e7-2ae55b3f95ac/download/
alternatively, you could just set it in env within that ipython notebook:
import os
os.environ['DANDI_API_KEY'] = "yourkey"
before you import dandi
etc so it could be picked up by that process and its children (may be... ;))
Similarly the export
you do in a child subshell in 3.
has no effect on the state of python process there. If within ipython notebook and just to do it interactively, can simply do how we do it in https://github.com/dandi/example-notebooks/blob/master/dandi/archive_stats.ipynb
client = DandiAPIClient()
client.dandi_authenticate()
which should prompt you for key if it is unknown.
I am running a notebook on dandihub and trying to download an embargoed file that I have access to. Even when providing my dandi api key, I get a prompt to enter a keyring password. I don't know where to find such a password. I don't have this error when running locally or Google collab, just Dandihub.
And the error (After entering an empty password to the keyring prompt):