Skip to content

pixie python API client always failed to validate the apikey #2216

@everestplusteam

Description

@everestplusteam

Describe the bug
I tried to connect self-hosted cloud with python API, and followed the instruction to generate apikey and cluster ID.
but the python sample code always failed with below errors:
Traceback (most recent call last):
File "/root/pixie-api-example/main.py", line 26, in
main()
~~~~^^
File "/root/pixie-api-example/main.py", line 9, in main
conn = px_client.connect_to_cluster('a355537a-8962-4b28-94ee-64e34479e912')
File "/root/pixie-api-example/.venv/lib/python3.13/site-packages/pxapi/client.py", line 588, in connect_to_cluster
cluster_info = self._get_cluster_info(cluster_id)
File "/root/pixie-api-example/.venv/lib/python3.13/site-packages/pxapi/client.py", line 555, in _get_cluster_info
return self._get_cluster(request)[0]
~~~~~~~~~~~~~~~~~^^^^^^^^^
File "/root/pixie-api-example/.venv/lib/python3.13/site-packages/pxapi/client.py", line 530, in _get_cluster
response: cpb.GetClusterInfoResponse = stub.GetClusterInfo(request, metadata=[
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
("pixie-api-key", self._token),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
("pixie-api-client", "python")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
])
^^
File "/root/pixie-api-example/.venv/lib/python3.13/site-packages/grpc/_channel.py", line 1181, in call
return _end_unary_response_blocking(state, call, False, None)
File "/root/pixie-api-example/.venv/lib/python3.13/site-packages/grpc/_channel.py", line 1006, in _end_unary_response_blocking
raise _InactiveRpcError(state) # pytype: disable=not-instantiable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Auth middleware failed: failed to fetch token - unauthenticated"
debug_error_string = "UNKNOWN:Error received from peer ipv4:34.102.151.106:443 {created_time:"2025-06-10T10:22:11.997274906+08:00", grpc_status:13, grpc_message:"Auth middleware failed: failed to fetch token - unauthenticated"}"

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem. Please make sure the screenshot does not contain any sensitive information such as API keys or access tokens.

import pxapi

def main():
# Create a Pixie client.
px_client = pxapi.Client(token="px-api-03397708-2978-4710-9beb-e40e38096e57")
# Connect to cluster.
conn = px_client.connect_to_cluster("a355537a-8962-4b28-94ee-64e34479e912")

# Define a PxL query with one output table.
PXL_SCRIPT = """
    import px
    df = px.DataFrame('http_events')[['resp_status','req_path']]
    df = df.head(10)
    px.display(df, 'http_table')
    """
# Execute the PxL script.
script = conn.prepare_script(PXL_SCRIPT)
# Print the table output.
for row in script.results("http_table"):
    print(row["resp_status"], row["req_path"])

if name == "main":
main()

Logs
Please attach the logs by running the following command:

./px collect-logs

App information (please complete the following information):

  • Pixie version
  • K8s cluster version
  • Node Kernel version
  • Browser version

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions