Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't see workbook connections using JWT #1548

Open
jbnitorum opened this issue Dec 30, 2024 · 3 comments
Open

Can't see workbook connections using JWT #1548

jbnitorum opened this issue Dec 30, 2024 · 3 comments
Labels
gap A gap in the library for existing server functionality Server-Side Enhancement

Comments

@jbnitorum
Copy link

jbnitorum commented Dec 30, 2024

I'm moving from using a PAT to using a JWT. The following code worked with a PAT but I can't seem to get it to work using a JWT. I've scoped everything and it says in the Tableau docs that you should be able to update connection details with a JWT. I'm getting an unauthorized error for this. I was able to do a number of other operations with the JWT, just not this one.

import tableauserverclient as TSC
import jwt
from datetime import timezone, datetime, timedelta
import uuid

jwt_token = jwt.encode(
    {
        "iss": client_id,
        "exp": datetime.utcnow() + timedelta(minutes=10),
        "jti": str(uuid.uuid4()),
        "aud": "tableau",
        "sub": "[email protected]",
        "scp": ["tableau:*"]}, ###everything in scope
        secret_key,
        algorithm = "HS256",
        headers = {
        'kid': secret_id,
        'iss': client_id
        }
)

tableau_auth = TSC.JWTAuth(token, 'my_site')
server = TSC.Server('https://us-east-1.online.tableau.com/', use_server_version=True)
with server.auth.sign_in(tableau_auth):
    for wb in TSC.Pager(server.workbooks):
        server.workbooks.populate_connections(wb)
        for connection in wb.connections: #### breaks here on wb.connections<<<<<
            creds = get_correct_creds(connection)
            if (creds):
                connection.username = creds["user"]
                connection.password = creds["password"]
                server.workbooks.update_conn(wb, connection)
@jorwoods
Copy link
Contributor

Query Workbook Connections does not show as supported for JWT, nor does Update Workbook Connection.

@jbnitorum
Copy link
Author

@jorwoods it looks like Update Workbook Connection does support JWT.

image

The same block is not present for Query Workbook Connections though. So if no JWT scope is listed it is not supported? I don't see anything explicitly saying there is no JWT support. As far as permissions go it just mentions 'Read' which aligns to a workbook JWT scope, but must mean something different.

Seems odd that you could update a connection but you can't query them. Ultimately you can still download the workbook with JWT which would provide access to connection information, right?

@jorwoods
Copy link
Contributor

jorwoods commented Dec 31, 2024

Ahh, update does support JWT. But yes, if not explicitly listed as supporting JWT, an endpoint does not support it. I agree it is strange that update connection is supported but querying the connections is not.

Downloading the workbook and inspecting the XML would give some of the information needed, but not the connection id.

@jacalata jacalata added Server-Side Enhancement gap A gap in the library for existing server functionality labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gap A gap in the library for existing server functionality Server-Side Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants