Authentification¶
This component is responsible for the authentication of the user in the Genomcore platform. It’s a complementary module mainly in charge of managing the refresh and token operations. However, it also alows to login from inside the library.
Login¶
Getting a token and refresh_token for a specific user. Use of .env file is recommended to store the credentials:
import os
from dotenv import load_dotenv
from genomcore.client import GenomcoreApiClient
load_dotenv(override=True)
auth_api = GenomcoreApiClient().auth
token, refresh_token = auth_api.login(
username=os.getenv("USERNAME"),
password=os.getenv("PASSWORD"),
organization_id=os.getenv("ORGANIZATION_ID"),
)
Refresh¶
Refreshing the token and refresh_token of the current session:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN", refresh_token="A_VALID_REFRESH_TOKEN")
token, refresh_token = api.auth.refresh()
Get All Users¶
Retrieving all users without filtering:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN")
users = api.users.get_all_users()
Retrieving users filtered by a list of IDs:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN")
users = api.users.get_all_users(ids=[56, 57, 58])
Get Users Frontdesk¶
Retrieving the frontdesk project associated with a user:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN")
project = api.users.get_users_frontdesk(userid=57)
Update User¶
Updating a user’s data by their ID:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN")
updated_user = api.users.update(userid=57, data={"email": "newemail@example.com"})
Updating a user that does not exist returns an empty dict:
from genomcore.client import GenomcoreApiClient
api = GenomcoreApiClient(token="A_VALID_TOKEN")
result = api.users.update(userid=9999, data={"email": "newemail@example.com"})
# result → {}