Auth¶
Auth helper: turn a browser cURL paste into client credentials.
Assists filling and renewing the cf_clearance token + matching User-Agent; it does NOT
defeat, solve, or automate the Cloudflare challenge — the human passes it in their own browser,
copies the request as cURL (bash), and pastes it here.
Fill (initial setup) and renew (after a stale token) follow the same paste-a-cURL path::
from vgmdb_client import Client
from vgmdb_client.auth import Credentials
from vgmdb_client.transport.errors import CloudflareChallengeError
client = Client.from_credentials(Credentials.from_curl(curl_text))
try:
album = client.get_album(4)
except CloudflareChallengeError:
# token went stale — re-solve in the browser, copy a fresh cURL, re-apply, retry
client.set_credentials(Credentials.from_curl(fresh_curl))
album = client.get_album(4)
Credentials
¶
Bases: BaseModel
An immutable cf_clearance token paired with the User-Agent it was issued for.
The two travel together because a cf_clearance cookie is only valid with the exact
User-Agent (and IP) it was minted for; pairing them prevents a mismatched, dead-on-arrival
token. Construct from a browser paste with :meth:from_curl.
Source code in src/vgmdb_client/auth/credentials.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
from_curl(curl_text)
classmethod
¶
Build credentials from a browser "Copy as cURL" paste.
Raises :class:~vgmdb_client.auth.errors.CurlParseError if the paste lacks a
cf_clearance cookie or a User-Agent, or cannot be tokenized.
Source code in src/vgmdb_client/auth/credentials.py
35 36 37 38 39 40 41 42 43 | |
to_config(**overrides)
¶
Build a :class:TransportConfig carrying this pair, forwarding extra config overrides
(e.g. timeout, min_interval, proxy).
Source code in src/vgmdb_client/auth/credentials.py
45 46 47 48 | |
CurlParseError
¶
Bases: VgmdbClientError
Raised when a pasted cURL command lacks a cf_clearance cookie or a User-Agent,
or cannot be tokenized as a shell command.
Source code in src/vgmdb_client/auth/errors.py
13 14 15 16 17 18 | |