Source code for galaxy.managers.api_keys

from galaxy.structured_app import BasicSharedApp

[docs]class ApiKeyManager:
[docs] def __init__(self, app: BasicSharedApp): = app
[docs] def create_api_key(self, user) -> str: guid = new_key = new_key.user_id = new_key.key = guid sa_session = sa_session.add(new_key) sa_session.flush() return guid
[docs] def get_or_create_api_key(self, user) -> str: # Logic Galaxy has always used - but it would appear to have a race # condition. Worth fixing? Would kind of need a message queue to fix # in multiple process mode. if user.api_keys: key = user.api_keys[0].key else: key = self.create_api_key(user) return key