Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/move_workbook_sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def main():
error = "No site named {} found.".format(args.destination_site)
raise LookupError(error)

tableau_auth.site = args.destination_site
tableau_auth.site_id = args.destination_site

# Signing into another site requires another server object
# because of the different auth token and site ID.
Expand Down
18 changes: 16 additions & 2 deletions tableauserverclient/models/tableau_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
class TableauAuth(object):
def __init__(self, username, password, site='', user_id_to_impersonate=None):
def __init__(self, username, password, site=None, site_id='', user_id_to_impersonate=None):
if site is not None:
import warnings
warnings.warn('TableauAuth(...site=""...) is deprecated, '
'please use TableauAuth(...site_id=""...) instead.',
DeprecationWarning)
site_id = site

self.user_id_to_impersonate = user_id_to_impersonate
self.password = password
self.site = site
self.site_id = site_id
self.username = username

@property
def site(self):
import warnings
warnings.warn('TableauAuth.site is deprecated, use TableauAuth.site_id instead.',
DeprecationWarning)
return self.site_id
2 changes: 1 addition & 1 deletion tableauserverclient/server/request_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def signin_req(self, auth_item):
credentials_element.attrib['name'] = auth_item.username
credentials_element.attrib['password'] = auth_item.password
site_element = ET.SubElement(credentials_element, 'site')
site_element.attrib['contentUrl'] = auth_item.site
site_element.attrib['contentUrl'] = auth_item.site_id
if auth_item.user_id_to_impersonate:
user_element = ET.SubElement(credentials_element, 'user')
user_element.attrib['id'] = auth_item.user_id_to_impersonate
Expand Down
2 changes: 1 addition & 1 deletion test/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_sign_in(self):
response_xml = f.read().decode('utf-8')
with requests_mock.mock() as m:
m.post(self.baseurl + '/signin', text=response_xml)
tableau_auth = TSC.TableauAuth('testuser', 'password', site='Samples')
tableau_auth = TSC.TableauAuth('testuser', 'password', site_id='Samples')
self.server.auth.sign_in(tableau_auth)

self.assertEqual('eIX6mvFsqyansa4KqEI1UwOpS8ggRs2l', self.server.auth_token)
Expand Down