tableau_tools icon indicating copy to clipboard operation
tableau_tools copied to clipboard

TableauHTTP#get_trusted_ticket_for_user doesn't work correctly

Open miau opened this issue 5 years ago • 0 comments

TableauHTTP#get_trusted_ticket_for_user fails when I pass the correct username.

Passing data in str to requests.post results in no Content-Type header. When you pass data in dict, Content-Type: header is set to application/x-www-form-urlencoded and Tableau Server parses this request correctly.

https://github.com/bryantbhowell/tableau_tools/blob/f04234ef93109543025f990f6e79f8da6f567b05/tableau_http.py#L15 These lines

        post_data = "username={}".format(username)
        if site.lower() != 'default':
            post_data += "&target_site={}".format(site)
        if client_ip is not None:
            post_data += "&client_id={}".format(client_ip)
        response = self.session.post(trusted_url, data=post_data)

should be:

        post_data = {"username": username}
        if site.lower() != 'default':
            post_data["target_site"] = site
        if client_ip is not None:
            post_data["client_id"] = client_ip
        response = self.session.post(trusted_url, data=post_data)

miau avatar Aug 28 '20 12:08 miau