Client#
- class PrescientClient(env_file: str | Path | None = None, settings: Settings | None = None)[source]#
Client for interacting with the Prescient API.
This client is used to authenticate, and for obtaining bucket credentials using the authenticated token. The client also provides helpers such as provding the STAC URL for the Prescient API, and authentication headers for making requests to the STAC API.
Token expiration is handled automatically for long running instances of the client (in a notebook for example).
- Configuration Options:
Construct the prescient_sdk.config.Settings object directly
Specify the path to an environment file containing configuration values
Do neither, and allow the client to build the Settings object using default methods (env variables, config.env file location in the working directory)
Note that you cannot specify the env_file location AND provide a Settings object.
- Parameters:
env_file (str | Path, optional) – Path to a configuration file. Defaults to None.
settings (Settings, optional) – Configuration settings for the client. Defaults to None.
- Raises:
ValueError – If both an environment file and a settings object are provided.
ValueError – If the provided configuration file is not found.
- property auth_credentials: dict#
Get the authorization credentials for the client.
- Returns:
access token:
{ "token_type": "string", "scope": "string", "expires_in": "int", "ext_expires_in": "int", "access_token": "string", "refresh_token": "string", "id_token": "string", "client_info": "string", "id_token_claims": { "aud": "string", "iss": "string", "iat": "int", "nbf": "int", "exp": "int", "aio": "string", "name": "string", "nonce": "string", "oid": "string", "preferred_username": "string", "rh": "string", "roles": ["string"], "sub": "string", "tid": "string", "uti": "string", "ver": "string", }, "token_source": "string", }
- Return type:
dict
- Raises:
ValueError – If the response status code is not 200, or if the access token is not in the response.
- property bucket_credentials#
Get bucket credentials using an auth access token
- Returns:
bucket temporary credentials:
{ "AccessKeyId": "string", "SecretAccessKey": "string", "SessionToken": "string", "Expiration": datetime(2015, 1, 1) }
- Return type:
dict
- Raises:
ValueError – If the credentials response is empty
- property credentials_expired: bool#
Checks to see if the client credentials have expired. Note: if auth credentials have expired, all credentials are considered expired as they all depend on auth credentials.
- Returns:
True - credentials are expired, False - credentials have NOT expired.
- Return type:
bool
- property headers: dict#
Get headers for a request, including the auth header with a bearer token.
- Returns:
The headers.
- Return type:
dict
- refresh_credentials(force=False)[source]#
Will refresh all the client credentials.
param force: If True will force the creds to be refreshed.
- Returns:
None
- property session: Session#
Get an AWS session for authenticating to the bucket
- Returns:
boto3 Session object
- Return type:
Session
- property stac_catalog_url: str#
Get the STAC URL.
- Returns:
The STAC URL.
- Return type:
str