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

Pass tokens via env variable or config file #56

Open
sbliven opened this issue Nov 27, 2023 · 2 comments
Open

Pass tokens via env variable or config file #56

sbliven opened this issue Nov 27, 2023 · 2 comments

Comments

@sbliven
Copy link

sbliven commented Nov 27, 2023

Summary

To avoid putting tokens or credientials in scripts and jupyter notebooks, I usually parse them from a config file. It would be nice to move this code inside pyscicat.

Current behavior

Creating a ScicatClient currently requires either a token or a username/password to be supplied. Providing only the base_url results in an AssertionError.

Proposed behavior

If neither token nor credentials are supplied, read them from the following sources:

  1. $SCICAT_TOKEN environmental variable
  2. $SCICAT_USER and $SCICAT_PASSWORD
  3. The file $XDG_CONFIG_HOME/scicat/config.ini (path subject to discussion) containing either of the above variables.

For instance, I might set /.config/scicat/config.ini to the following:

SCICAT_USER = ingestor
SCICAT_PASSWORD = myp4ssw0rd
@sbliven
Copy link
Author

sbliven commented Nov 27, 2023

There are a few things open for discussion:

  • Spelling of the variables and paths
  • Format for the config file (ini, toml, bash-like, yaml, json)

@sbliven
Copy link
Author

sbliven commented Nov 27, 2023

I often want to switch between production and development tokens. Maybe this could also be added somehow in the config (eg different ini sections for each environment, plus an easy way to switch between them).

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

No branches or pull requests

1 participant