Handling Configuration#
There are three ways to configure the PrescientClient:
Set the values inline using the
Settingsobject directlyUse a DotEnv file located in the project directory
Set environment variables
Authentication Providers#
The SDK supports two OAuth2 authentication providers, selected via the prescient_auth_provider setting:
Provider |
Default |
Provider-specific required field |
|---|---|---|
|
yes |
|
|
|
The settings prescient_endpoint_url, prescient_client_id, and prescient_auth_url are required regardless of provider. For optional configuration, see the documentation for the config class
1. Set the values inline using the Settings object#
Note that configuration values set in this way will take precendence over all other methods.
Microsoft (default)#
from prescient_sdk.client import PrescientClient
from prescient_sdk.config import Settings
settings = Settings(
prescient_endpoint_url="https://example.prescient.earth",
prescient_auth_provider="microsoft",
prescient_tenant_id="a-tenant-id",
prescient_client_id="a-client-id",
prescient_auth_url="https://auth-url.com/path/to/oauth2/token",
)
client = PrescientClient(settings=settings)
Google#
from prescient_sdk.client import PrescientClient
from prescient_sdk.config import Settings
settings = Settings(
prescient_endpoint_url="https://example.prescient.earth",
prescient_auth_provider="google",
prescient_client_id="a-client-id.apps.googleusercontent.com",
prescient_google_client_secret="a-client-secret",
prescient_auth_url="https://oauth2.googleapis.com/token",
)
client = PrescientClient(settings=settings)
2. Use a DotEnv file#
An alternative to the above method is to use a DotEnv file. Note that each configuration value is capitalized.
Microsoft (default)#
PRESCIENT_ENDPOINT_URL="https://example.prescient.earth"
PRESCIENT_AUTH_PROVIDER="microsoft"
PRESCIENT_TENANT_ID="a-tenant-id"
PRESCIENT_CLIENT_ID="a-client-id"
PRESCIENT_AUTH_URL="https://auth-url.com/path/to/oauth2/token"
Google#
PRESCIENT_ENDPOINT_URL="https://example.server.prescient.earth"
PRESCIENT_AUTH_PROVIDER="google"
PRESCIENT_CLIENT_ID="a-client-id.apps.googleusercontent.com"
PRESCIENT_GOOGLE_CLIENT_SECRET="a-client-secret"
PRESCIENT_AUTH_URL="https://oauth2.googleapis.com/token"
# The path to where you store the env_file must be specified
client = PrescientClient(env_file="/path/to/env_file")
3. Use environment variables#
If you set environment variables and use a DotEnv file, each environment variable that is set will override the corresponding value in the DotEnv file.
Environment variables must be capitalized
As an example, if you are using a bash shell, you can set a single variable like so:
export PRESCIENT_ENDPOINT_URL="https://example.prescient.earth"
# Environment Variables are read in automatically, so you can just do this:
client = PrescientClient()