Skip to content

Support logins with personal access token for Tableau Cloud#3

Merged
nekketsuuu merged 3 commits into
masterfrom
nekketsuuu-pat
Jun 22, 2026
Merged

Support logins with personal access token for Tableau Cloud#3
nekketsuuu merged 3 commits into
masterfrom
nekketsuuu-pat

Conversation

@nekketsuuu

Copy link
Copy Markdown
Contributor

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"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current API version of Tableau Cloud.

@nekketsuuu nekketsuuu requested review from a team, errm and fsan June 18, 2026 15:20
@eagletmt eagletmt requested a review from Copilot June 22, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Server to accept PAT parameters, add current_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

  • Client previously exposed #username via attr_reader, and it is still meaningful for password-based sign-in. Removing it is a breaking change for any callers using Client directly. Consider exposing #credentials and restoring #username as a derived accessor (returning nil for 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.

Comment thread lib/tableau_server_client/client.rb Outdated
Comment on lines +37 to +40
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intended breaking change.

Comment thread lib/tableau_server_client/server.rb
Comment on lines +14 to +16
# 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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to PAT support? Is it prone to failing with 429, 500, ...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment on lines +31 to +32
spec.add_dependency 'faraday', '>= 2.0'
spec.add_dependency 'faraday-retry', '>= 2.0'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll do.

Comment thread lib/tableau_server_client/server.rb
@nekketsuuu

Copy link
Copy Markdown
Contributor Author

Thanks for reviews!

@nekketsuuu nekketsuuu merged commit 4ccf8a5 into master Jun 22, 2026
1 check passed
@nekketsuuu nekketsuuu deleted the nekketsuuu-pat branch June 22, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants