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()