The create function is the primary way to instantiate a Client. It automates the process of detecting credentials from multiple sources, setting up a token retriever, and creating an authenticated HTTP session.
To use it, provide a list of credential sources (such as dictionaries containing username and password), the token_url for OAuth authentication, and optional factory functions for customization.
If no valid credentials are found across the provided sources, it raises MissingCredentials. If multiple conflicting credential sources are detected, it raises MultipleCredentialsSources.
from up42.http import client
# Example usage with explicit credentials
credential_sources = [{"username": "my_user", "password": "my_password"}]
token_url = "https://auth.up42.com/token"
up42_client = client.create(
credential_sources=credential_sources,
token_url=token_url
)
# up42_client is an instance of Client and can be used for API requests