Repository navigation
Embedding a password (for scheduling an extract) does not work #1062
Description
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
jorwoods commentedon Jun 28, 2022
@jog-ioki When you run the
populate_connectionscall, it does not fetch the password. Then when you callupdate_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?jog-ioki commentedon Jun 29, 2022
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.jorwoods commentedon Jul 11, 2022
@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 referencingworkbook.connectionsagain between the time of making the changes and the publish? Theconnectionsproperty 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.connectionsagain, your changes are lost.Try this, and let us know if it works.
jog-ioki commentedon Aug 29, 2022
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:
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.
jorwoods commentedon Aug 29, 2022
@jog-ioki Looking at the code, it evaluates the password in the
ifstatement 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 stringjog-ioki commentedon Aug 29, 2022
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
requestlib 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!
Use explicit None identity check for datasource updates (#1099)
Use explicit None identity check for datasource updates (#1099)
prepare release 0.20 (tableau#1107)
prepare release 0.20 (tableau#1107)