Support logins with personal access token for Tableau Cloud#3
Conversation
When 4xx/5xx, the raise_error middleware decodes query params, but sometimes they are empty.
|
|
||
| #Implement for_token | ||
| #def for_token(token) | ||
| DEFAULT_API_VERSION = "3.21" |
There was a problem hiding this comment.
The current API version of Tableau Cloud.
There was a problem hiding this comment.
Pull request overview
This PR adds support for authenticating to Tableau Cloud using Personal Access Tokens (PAT) by introducing a credentials abstraction and wiring it through Server/Client, along with a couple of Cloud-specific behavior adjustments.
Changes:
- Add
TableauServerClient::Credentials(password vs PAT) and update sign-in request building to use it. - Update
Serverto accept PAT parameters, addcurrent_site, and block impersonation when using PAT. - Upgrade HTTP stack to Faraday v2 with
faraday-retry, and harden extract-refresh parsing for Cloud’s schedule shape.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tableau_server_client.gemspec | Raises minimum Ruby version and updates Faraday dependencies to v2 + retry middleware. |
| lib/tableau_server_client/server.rb | Adds PAT sign-in options, credentials plumbing, Cloud notes, and current_site; adjusts impersonation behavior. |
| lib/tableau_server_client/client.rb | Switches sign-in to credentials-driven attributes; adds Faraday retry middleware; tweaks query param decoding. |
| lib/tableau_server_client/credentials.rb | New credentials types (Password/PAT) with redacted inspect and capability flags. |
| lib/tableau_server_client/resources/extract_refresh.rb | Makes schedule_id parsing nil-safe for Tableau Cloud responses. |
Comments suppressed due to low confidence (1)
lib/tableau_server_client/client.rb:33
Clientpreviously exposed#usernameviaattr_reader, and it is still meaningful for password-based sign-in. Removing it is a breaking change for any callers usingClientdirectly. Consider exposing#credentialsand restoring#usernameas a derived accessor (returningnilfor PAT).
def initialize(server_url, credentials, content_url, api_version, token_lifetime, logger, impersonation_user_id)
@server_url = server_url
@credentials = credentials
@content_url = content_url
@api_version = api_version
@token_lifetime = token_lifetime
@logger = logger
@impersonation_user_id = impersonation_user_id
end
attr_reader :content_url, :api_version, :token_lifetime, :logger, :impersonation_user_id
def server_url
@_server_url ||= URI(@server_url.chomp("/"))
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| attr_reader :server_url, :content_url, :api_version, :token_lifetime, :logger, :impersonation_username | ||
|
|
||
| # Tableau Server only: lists every site on the server. Not available on Tableau Cloud, | ||
| # where you can only access the site you signed in to. Use #current_site instead. |
There was a problem hiding this comment.
This is an intended breaking change.
| # Tableau Server returns <schedule id="..."> but Tableau Cloud returns | ||
| # an inline schedule (frequency/nextRunAt) with no id, so guard against nil. | ||
| attrs['schedule_id'] = xml.xpath("xmlns:schedule/@id").first&.value |
There was a problem hiding this comment.
This is a valid comment, but I decided not to address it this time and will change the behavior later if necessary.
|
|
||
| def faraday | ||
| @faraday ||= Faraday.new(request: {params_encoder: EmptyEncoder.new}, headers: {'Content-Type' => 'application/xml'}) do |f| | ||
| f.request :retry, |
There was a problem hiding this comment.
Is this related to PAT support? Is it prone to failing with 429, 500, ...?
There was a problem hiding this comment.
It is not entirely related. The reason I included the retry settings is that I reviewed the configuration while upgrading to Faraday v2 as part of this change, and also because I encountered very occasional errors when running it against Tableau Cloud locally.
| spec.add_dependency 'faraday', '>= 2.0' | ||
| spec.add_dependency 'faraday-retry', '>= 2.0' |
|
Thanks for reviews! |
https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_auth.htm