Skip to content

Embedding a password (for scheduling an extract) does not work #1062

Closed

Description

@jog-ioki

Describe the bug
We are currently trying to automate the creation of workbooks on the server via Tableau APIs. Version is:

print(server.server_info.get())
ServerInfoItem: [product version: 2022.1.1, build no.:20221.22.0415.1144, REST API version:3.15]

All our workbooks have an embedded connection string to a PostgreSQL database (no published datasource!) All workbooks contain their own and a custom SQL is “contained” in each of datasource per workbook)
Uploading with a live connection works
We now try to get some workbooks and create an Extract for them. Here is example code (note that this is unrelated to TSC)

from tableau_api_lib import TableauServerConnection
srv = TableauServerConnection(tableau_server_config, env='PROD')
srv.sign_in()
 
response = srv.query_sites()
site_list = [(site['name'], site['id']) for site in response.json()['sites']['site']]
 
workbooks_df = get_workbooks_dataframe(srv)[['name', 'id']]
what_to_search = ['xyz']
 
workbooks_df = workbooks_df[workbooks_df['name'].isin(what_to_search)]
response = srv.create_extracts_for_workbook(workbook_id=workbooks_df.id.iloc[0])

Running this will give us an error like:

    Affected data source
    Embedded in workbook
    Error message
    Connectionless Failure (status code = 10000, Missing password. Invalid username or password.)
    Requested at
    June 21, 2022, 1:25 PM
    Requested by
    xx@xx.com
    Failed at
    June 21, 2022, 1:25 PM
    Suggested action
    **Check the Data Connection page for necessary updates to an access token or embedded credentials.**

The action seem to be clear – we need to embed the password.

Problem: We are not able to embed the password to start the extract.
Here is the code - we tried using TSC for it:

token = TSC.PersonalAccessTokenAuth(token_name='xxx', personal_access_token=pat, site_id='')
server = TSC.Server("xxx", use_server_version=True)
with server.auth.sign_in(token):
   
    workbook = server.workbooks.get_by_id('xyz')
    server.workbooks.populate_connections(workbook)
    connection1 = workbook.connections[0]
 
    datasource1 = server.datasources.get_by_id(connection1.datasource_id)
    server.datasources.populate_connections(datasource1)
 
    connection1.embed_password=True
 
    server.workbooks.update_connection(workbook, connection1)

Versions
Details of your environment, including:

  • Tableau Server version: [product version: 2022.1.1, build no.:20221.22.0415.1144, REST API version:3.15]
  • Python version: 3.8
  • TSC library version: ==0.19.0

To Reproduce
see code last snipped

Results
Fails silently (no error message, but embed_password flag remains false)

NOTE: Be careful not to post user names, passwords, auth tokens or any other private or sensitive information.

Activity

  1. jorwoods commented on Jun 28, 2022

    @jorwoods
    Contributor

    @jog-ioki When you run the populate_connections call, it does not fetch the password. Then when you call update_connection, you are passing the connection WITHOUT a password. Therefore, it cannot embed the password to run refreshes. Did you just remove the lines where you are setting the password on the connection?

  2. jog-ioki commented on Jun 29, 2022

    @jog-ioki
    Author

    Did you just remove the lines where you are setting the password on the connection?

    sorry. should have mentioned that. i tried to explicitly set the username/pwd as well. Problem was always that valueembed_password never switched to True.

        workbook = server.workbooks.get_by_id('xyz')
        server.workbooks.populate_connections(workbook)
        connection1 = workbook.connections[0]
     
        datasource1 = server.datasources.get_by_id(connection1.datasource_id)
        server.datasources.populate_connections(datasource1)
        
        connection1.username='jhdsfga'
        connection1.password=''
        connection1.embed_password=True
     
        server.workbooks.update_connection(workbook, connection1)
    
  3. added
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Jul 11, 2022
  4. jorwoods commented on Jul 11, 2022

    @jorwoods
    Contributor

    @jog-ioki I am able to in my testing successfully update the connection. I have a suspicion as to what is happening.

    After you update the attributes of connection1, are you referencing workbook.connections again between the time of making the changes and the publish? The connections property on both the workbook and datasource items is a function that calls the API and fetches a new list. If you make changes, then call .connections again, your changes are lost.

    Try this, and let us know if it works.

    from copy import deepcopy
    
    workbook = server.workbooks.get_by_id('xyz')
    server.workbooks.populate_connections(workbook)
    connection1 = deepcopy(workbook.connections[0])
    
    datasource1 = server.datasources.get_by_id(connection1.datasource_id)
    server.datasources.populate_connections(datasource1)
       
    connection1.username='jhdsfga'
    connection1.password=''
    connection1.embed_password=True
    
    server.workbooks.update_connection(workbook, connection1)
  5. jog-ioki commented on Aug 29, 2022

    @jog-ioki
    Author

    i am very sorry to get back to You so late!
    Thanks for Your input!!

    It does not work in my setup.

    Some things that might be special:

    • Is the database in use of any interest? (I use PostgreSQL v13)
    • I really set no password - it is an empty string. Did You do the same?
    • What workbook did You use? One that also was published by the API or an example workbook that You created/uploaded manually? (i am wondering if there is something regarding privileges?)

    Sorry maybe those question are totally irrelevant, i am just thinking out loud what might be the difference here.
    I will also try to deinstall the TSC binaries and install again...old but gold.

  6. jorwoods commented on Aug 29, 2022

    @jorwoods
    Contributor

    @jog-ioki Looking at the code, it evaluates the password in the if statement directly. Since an empty string is falsey, it therefore never adds a password attribute to the update request. Since the password attribute is not in the update request, it cannot be changed to an embedded password.

    I can put in a pull request to do an identity comparison to None, but that would take a while to be deployed. The easiest fix is to use a password that is not an empty string

  7. jog-ioki commented on Aug 29, 2022

    @jog-ioki
    Author

    Okay cool. That explains it. Thanks for checking!
    i only reported that issue because i thought it is nice if Tableau at least know that there is an issue.
    We solved it at our end by using request lib and executing pure REST calls. That worked - so i don't have time pressure.
    I still think some kind of a message -maybe a warning - would be nice (It just fails silently).
    So i leave it up to You and i will not complain if You close the issue :)

    Thanks again for taking the time to look into it!! Appreciate that!

  8. removed
    help wantedA user needs help, may be a mistake, a bug or a feature request
    on Aug 30, 2022
  9. added a commit that references this issue on Sep 1, 2022
    00f55bb
  10. added a commit that references this issue on Sep 20, 2022
    c1295c6
  11. added a commit that references this issue on Dec 12, 2024
    3c021c0
  12. added a commit that references this issue on May 5, 2026
    3eb2b91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions