hoechenberger / openneuro-py

A client for accessing OpenNeuro datasets, written in Python.
GNU General Public License v3.0
61 stars 12 forks source link

Add token arg to download() for in-script use #175

Closed DominiqueMakowski closed 4 months ago

DominiqueMakowski commented 4 months ago

Hi, I'm using the on.download() function interactively from a jupyter notebook (not from the terminal) and I was wondering if it was possible to add an argument to download() to be able to pass a token to access unpublished datasets? Thanks

hoechenberger commented 4 months ago

Hello, I'd rather not do that, as the token would end up in your Python command history and potentially in a shared notebook etc. Remember that this is a credential that's meant to be kept secret.

Can you try storing the token via openneuro.login()? (I've never tried it in a Notebook though!)

An alternative could be adding support for retrieving it from an env var.

cc @wmvanvliet @cbrnr

cbrnr commented 4 months ago

Seems like the available config/login mechanism already supports access tokens, so I'm not sure I understand the problem. Is it specific to notebooks?

DominiqueMakowski commented 4 months ago

Thanks! I guess I was asking if a more straightforward and reproducible (i.e., that doesn't depend on external config files) way of accessing unpublished datasets existed. I looked at login() and I naively thought that I could have a script like:

import openneuro as on

token = "blabla"
on.login(token)
on.download(...)

But login() doesn't take input arguments...

, as the token would end up in your Python command history and potentially in a shared notebook

Security is a fair point, but still, one could provide the option to do this and then perhaps add a warning that this might be unsafe?

hoechenberger commented 4 months ago

No, sorry, I won't do that, it's a huge security risk. I'd consider adding support for an env var though if that would help you.

DominiqueMakowski commented 4 months ago

It's alright, don't worry, thanks!

hoechenberger commented 4 months ago

Thanks for your understanding, @DominiqueMakowski!