Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Mage ai Mage ai Tableau Client

From Leeroopedia


Knowledge Sources
Domains Data_Integration, Tableau, API
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete HTTP client for making authenticated requests to the Tableau REST API, provided by the Mage Tableau source connector.

Description

The TableauClient class manages all HTTP communication with a Tableau Server or Tableau Online instance. Unlike other clients in this codebase that use Bearer tokens, it authenticates using the X-Tableau-Auth header with the access token. The base URL is provided externally (typically constructed from the Tableau server address and API version). The client is implemented as a context manager, verifying the access token on entry by hitting the /workbooks endpoint and closing the session on exit. Rate limiting is enforced via the Singer @utils.ratelimit(1000, 60) decorator. It uses Singer metrics.http_request_timer for request timing instrumentation. Configurable request timeout defaults to 300 seconds.

Usage

Used internally by Tableau stream classes. Requires access_token, base_url, and optionally request_timeout and user_agent.

Code Reference

Source Location

  • Repository: mage-ai
  • File: mage_integrations/mage_integrations/sources/tableau/client.py
  • Lines: 1-252

Signature

class TableauClient(object):
    def __init__(
        self,
        logger,
        access_token,
        base_url,
        config_request_timeout,
        user_agent=None,
    ):

Import

from mage_integrations.sources.tableau.client import TableauClient

I/O Contract

Inputs

Name Type Required Description
logger Logger Yes Logger instance for diagnostic output
access_token str Yes Tableau authentication token, sent via X-Tableau-Auth header
base_url str Yes Base URL for the Tableau REST API (e.g., https://server/api/3.x/sites/{site_id})
config_request_timeout float/str Yes Request timeout in seconds (defaults to 300 if falsy)
user_agent str No Optional User-Agent header value

Outputs

Name Type Description
response dict Parsed JSON response from the Tableau REST API

Key Methods

Method Description
check_access_token() Validates the token by querying /workbooks. Checks for workbooks key in response.
request(method, path, url, **kwargs) Core request method with rate limiting, metric timing, X-Tableau-Auth header, and error handling.
get(path, **kwargs) Convenience wrapper for GET requests with logging.
post(path, **kwargs) Convenience wrapper for POST requests.
perform(method, path, **kwargs) Dispatches to get or post based on method string.

Error Handling

Defines a hierarchy of custom exceptions mapped to HTTP status codes (400, 401, 402, 403, 404, 405, 406, 408, 409, 415, 422, 423, 500). Falls back to TableauError for unmapped codes. Raises Server5xxError for status codes >= 500.

Usage Examples

from mage_integrations.sources.tableau.client import TableauClient

with TableauClient(
    logger=logger,
    access_token='your_tableau_auth_token',
    base_url='https://your-server.com/api/3.14/sites/site-id',
    config_request_timeout=300,
) as client:
    workbooks = client.get('workbooks')
    views = client.get('views')

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment