connect() and auth¶
How connect() picks a credential is explained in the
authentication guide.
connect
¶
connect(profile: str | None = None, *, secret_key: str | None = None, jwt: str | None = None, api_host: str | None = None, license: str | None = None, interactive: bool | None = None, validate: bool = True, sandbox: bool | None = None, spec: Literal['auto', 'bundled'] | None = None, rate_limit: float | None = 10.0, concurrency: int = 10, timeout: float = DEFAULT_TIMEOUT, log_http: bool | None = None, transport: BaseTransport | None = None, verify: bool | str = True, proxy: str | None = None) -> T3Client
Find a credential and return a validated T3Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile
|
str | None
|
Saved profile to use. Defaults to |
None
|
secret_key
|
str | None
|
Use this secret key. Wins over everything else. |
None
|
jwt
|
str | None
|
Use this JWT. |
None
|
api_host
|
str | None
|
T3 API base URL. Defaults to |
None
|
license
|
str | None
|
Default license for calls that need one. Defaults to
|
None
|
interactive
|
bool | None
|
|
None
|
validate
|
bool
|
Check the credential with |
True
|
sandbox
|
bool | None
|
Exchange the credential for a Metrc sandbox JWT. Defaults to
|
None
|
spec
|
Literal['auto', 'bundled'] | None
|
|
None
|
rate_limit
|
float | None
|
Requests per second across all threads. |
10.0
|
concurrency
|
int
|
Threads used to fetch collection pages. |
10
|
timeout
|
float
|
Request timeout in seconds. |
DEFAULT_TIMEOUT
|
log_http
|
bool | None
|
Log every request and response at DEBUG, with secrets
masked. Defaults to |
None
|
transport
|
BaseTransport | None
|
An |
None
|
verify
|
bool | str
|
TLS verification, as in httpx2. |
True
|
proxy
|
str | None
|
Proxy URL, as in httpx2. |
None
|
Raises:
| Type | Description |
|---|---|
AuthRequired
|
no credential and no terminal to ask in. |
AuthError
|
the credential was rejected. |
SecretKeys
¶
client.secret_keys: manage the account's secret keys.
list
¶
Every secret key on the account, with isEnabled, isManaged and lastUsedAt.
create
¶
create(hostname: str, username: str, password: str, email: str | None = None, otp_seed: str | None = None) -> str
Create a secret key and return it. See create_secret_key.
rotate
¶
rotate(key: str, *, password: str, username: str | None = None, hostname: str | None = None, email: str | None = None, otp_seed: str | None = None) -> dict[str, Any]
Update the Metrc credentials behind a key after a password, email or OTP change.
The key value doesn't change. username and hostname default to
the profile's, then to whoami.
delete
¶
Delete a key. Managed keys can't be deleted (the server answers 403).
Profile
dataclass
¶
Profile(name: str, api_host: str = DEFAULT_HOST, metrc_hostname: str | None = None, username: str | None = None, license: str | None = None, credential: CredentialKind | None = None)
A saved login. Secrets aren't stored here; see Store.
SecretKeyAuth
¶
Bases: Auth
Sends a T3 secret key in the X-T3-API-Key header.