tdfs4ds.utils.session_token¶
tdfs4ds.utils.session_token
¶
Renew a session token from the platform, where the platform provides one.
On Teradata AI Studio, %gen_token calls the platform module
oauth_token_helper (/opt/oauth_token_helper.py), which asks the
JupyterHub hub for the user's current token; the hub renews it every 20
minutes. Any process of the user's server can call it, so a process that runs
longer than a token (the app) can renew its own instead of failing two hours
after it started.
Inert everywhere else, by construction:
- no
oauth_token_helpermodule -> :func:platform_tokenreturnsNoneand nothing changes; - only a connection that already logs on with a token
(
TDFS4DS_TD_LOGDATA='token=...') is renewed; a password logon is never touched, and the Vector Store / MCP settings are renewed only when they already carry a token.
tdfs4ds reads no unprefixed variable here: the platform's module does, the
same way %gen_token does.
platform_token
¶
A current token from the platform's oauth_token_helper, or None.
None when the module does not exist (any environment but AI Studio) or the platform could not answer. Never raises.
uses_token_logon
¶
True when the database logon in environ (default os.environ) is a token.
apply_token
¶
Put token everywhere this session already uses a token. Returns what changed.
TDFS4DS_TD_LOGDATA(the logon an automatic reconnect uses);- the Vector Store token, then
set_auth_tokenagain, when one is set; - the MCP
Authorization: Bearerheader, when one is set.
refresh_now
¶
Renew once. True when a new token was applied; False when nothing to do.
start_refresher
¶
Renew the token in the background every interval seconds. True when running.
Started only when the logon is a token and the platform provides one; a second call does nothing.