KNOWLEDGE BASE

Tableau Server Client Python Error "NotSignedInError: Missing site ID. You must sign in first.


Published: 29 Sep 2021
Last Modified Date: 30 Sep 2021

Issue

When trying to query, an error appears that states that you have not signed in, but you have authenticated properly as you able to retrieve datasource information. 
"NotSignedInError: Missing site ID. You must sign in first."

Environment

  • Tableau Online 
  • API
  • Python
  • Tableau Server Client
  • Snowflake

Resolution

Use sign-in code similar to the following examples.

# create credential objects

tableau_auth = TSC.TableauAuth(userID, pwd, site_id='')

server = TSC.Server(URL)

 

# sign in

server.auth.sign_in(tableau_auth)

 

# create new user

newU = TSC.UserItem('Test', 'Interactor')

newU = server.users.add(newU)

print(newU.name, newU.site_role)

 

#sign out

server.auth.sign_out()

 

 

or use with to let the code handle the sign out for you:

# create credential objects

tableau_auth = TSC.TableauAuth(userID, pwd, site_id='')

server = TSC.Server(URL)

 

# sign in

with server.auth.sign_in(tableau_auth):

     # create new user

     newU = TSC.UserItem('Test', 'Interactor')

     newU = server.users.add(newU)

     print(newU.name, newU.site_role)

Cause

No properly formatted sign-in code or missing sign-in code.
Did this article resolve the issue?