Created
June 14, 2024 13:49
-
-
Save mvdbeek/5827afd57d5e96343a0c0d8d4140198c to your computer and use it in GitHub Desktop.
create api key example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run from galaxy root with PYTHONPATH=lib GALAXY_CONFIG_FILE=config/galaxy.yml python example.py | |
import os | |
from scripts.db_shell import config | |
from galaxy.celery import get_galaxy_app | |
from galaxy.managers.api_keys import ApiKeyManager | |
EMAIL = "[email protected]" | |
os.environ["GALAXY_CONFIG_FILE"] = os.environ.get("GALAXY_CONFIG_FILE", config["config_file"]) | |
app = get_galaxy_app() | |
user = app.user_manager.by_email(EMAIL) or app.user_manager.create(email=EMAIL, username="abcd", password="abcdef") | |
key = ApiKeyManager(app).get_or_create_api_key(user) | |
print(key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment