You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: consolidate auth samples into a single samples/login.py
Merge the previously-separate samples/auth_from_env.py into samples/login.py
so there is one canonical demo of how to sign in to Tableau Server. The
consolidated sample now supports three credential sources composed in
precedence order: CLI args, TABLEAU_* env vars, and (with --interactive)
a getpass password prompt. Env-var names are TABLEAU_-prefixed to avoid
collision with generic shell vars like USERNAME (which Windows sets
automatically for the current OS user).
Public helpers on samples/login.py:
- sample_define_common_options(parser) -- unchanged name; adds
--interactive and --api-version.
- get_env(key, default=None) -- unchanged name.
- resolve_credentials(args) -- new; CLI -> env -> prompt.
- build_server_and_auth(args) -- new; returns (Server, Auth)
without signing in, replacing load_from_env's return shape.
- sample_connect_to_server(args) -- unchanged name; now calls
resolve_credentials + build_server_and_auth then signs in.
- set_up_and_log_in() -- unchanged main entry.
Removes the "Personal Access Token:" getpass fallback in
sample_connect_to_server -- nobody wants to type a 40-character random
string; a missing PAT half now raises the partial-credentials error.
The password getpass prompt is likewise gated on --interactive rather
than triggering silently on a missing --password.
Env-var rename (breaks anyone relying on the pre-change bare names in
login.py::get_env calls, though no other sample called those helpers):
SERVER -> TABLEAU_SERVER
SITE -> TABLEAU_SITE
TOKEN_NAME -> TABLEAU_TOKEN_NAME
TOKEN_VALUE -> TABLEAU_TOKEN
samples/auth_from_env.py is deleted; its load_from_env() shape is now
available as resolve_credentials(args) + build_server_and_auth(args).
The README subsection is retained but points at samples/login.py and
documents the three-source precedence.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
*`TABLEAU_API_VERSION` (optional) — pin REST API version; otherwise
33
+
the sample negotiates with the server
34
+
3. Pass `--interactive` to prompt for a missing password on a terminal
35
+
via `getpass` instead of exporting it. PATs are never prompted for.
36
+
37
+
Names are `TABLEAU_`-prefixed to avoid collision with generic shell
38
+
variables like `USERNAME` (which Windows sets automatically).
39
+
19
40
To contribute, see our [Developer Guide](https://tableau.github.io/server-client-python/docs/dev-guide). A list of all our contributors to date is in [CONTRIBUTORS.md].
0 commit comments