Automate Credentials for DSS Export to Folder (Tableau Server Publish)

Solved!
manishgupta_430
Level 1
Automate Credentials for DSS Export to Folder (Tableau Server Publish)

We are working towards fully automating DSS data processing steps via scenarios and we are looking for a way to automate Export to Folder recipe for publishing DSS datasets to Tableau server.

Currently, each team member requires to input his/her credentials in export recipe and scenarios based on these recipes fails when User Credentials expires.

As the number of projects/export recipes are growing, we are looking for a way so that either publishing to Tableau Server gets automated completely or a user has to just enter/modify his credentials only at one place.

Few suggested options listed below, but we do not know how these works and whether they will resolve this issue:

  • User secrets
  • Use presets
  • Recipe properties/variables
  • DSS Personal Credentials
  • Local variables (But Password should be masked or encrypted)
1 Solution
pmasiphelps
Dataiker

Hi,

 

I think the best way to do this is via user secrets, scenarios, and a python API script (as a scenario step) to update the tableau export recipe with the user's credentials.

 

Each user can add secrets for their tableau username and password. Make sure the name of each secret (tableau_username, tableau_password) is consistent. (see first screenshot)

 

In each export to tableau recipe, you can find the recipe name in the URL or top banner. (see second screenshot)

In a scenario, add a python step, and paste the following code (the indentations in the for loop/if statements may not come through this message correctly - please check those). Make sure to update the project key with your project key, and the tableau export recipe name with your tableau export recipe name. (see third screenshot)

 

## start of code ##

import dataiku
from dataiku import pandasutils as pdu
import pandas as pd

client = dataiku.api_client()

auth_info = client.get_auth_info(with_secrets=True)

# retrieve the tableau username and password secrets
tableau_username = None
tableau_password = None

for secret in auth_info["secrets"]:
if secret["key"] == "tableau_username":
tableau_username = secret["value"]
elif secret["key"] == "tableau_password":
tableau_password = secret["value"]

# replace this project key with your project key
proj = client.get_project("LOANDEFAULTSMS")

# replace this recipe name with your recipe name
tableau_recipe = proj.get_recipe("compute_6va2HSi1")

recipe_sett = tableau_recipe.get_settings()

# set the tableau export recipe params with the user credentials
recipe_sett.get_recipe_params()['exportParams']['config']['username'] = tableau_username
recipe_sett.get_recipe_params()['exportParams']['config']['password'] = tableau_password

recipe_sett.save()

## end of code ##

 

Let me know if that works!

 

Best,

Pat

View solution in original post

2 Replies
pmasiphelps
Dataiker

Hi,

 

I think the best way to do this is via user secrets, scenarios, and a python API script (as a scenario step) to update the tableau export recipe with the user's credentials.

 

Each user can add secrets for their tableau username and password. Make sure the name of each secret (tableau_username, tableau_password) is consistent. (see first screenshot)

 

In each export to tableau recipe, you can find the recipe name in the URL or top banner. (see second screenshot)

In a scenario, add a python step, and paste the following code (the indentations in the for loop/if statements may not come through this message correctly - please check those). Make sure to update the project key with your project key, and the tableau export recipe name with your tableau export recipe name. (see third screenshot)

 

## start of code ##

import dataiku
from dataiku import pandasutils as pdu
import pandas as pd

client = dataiku.api_client()

auth_info = client.get_auth_info(with_secrets=True)

# retrieve the tableau username and password secrets
tableau_username = None
tableau_password = None

for secret in auth_info["secrets"]:
if secret["key"] == "tableau_username":
tableau_username = secret["value"]
elif secret["key"] == "tableau_password":
tableau_password = secret["value"]

# replace this project key with your project key
proj = client.get_project("LOANDEFAULTSMS")

# replace this recipe name with your recipe name
tableau_recipe = proj.get_recipe("compute_6va2HSi1")

recipe_sett = tableau_recipe.get_settings()

# set the tableau export recipe params with the user credentials
recipe_sett.get_recipe_params()['exportParams']['config']['username'] = tableau_username
recipe_sett.get_recipe_params()['exportParams']['config']['password'] = tableau_password

recipe_sett.save()

## end of code ##

 

Let me know if that works!

 

Best,

Pat

manishgupta_430
Level 1
Author

This solution worked for us ! Thank you for your help

0 Kudos