Hello, I am trying to use the gRPC API to retrieve device info from Chirpstack in a python script.
I have created 2 API keys:
- 1 global created under Network Server
- 1 created in a Tenant
When using ListGatewaysRequest(), I can specify the tenant_id, so the request works with both key
However, when using ListDevicesRequest(), I am not able to specify the tenant_id and it only works with the global key. With the Tenant key i get this error:
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAUTHENTICATED
details = ""
debug_error_string = "UNKNOWN:Error received from peer {grpc_message:"", grpc_status:16, created_time:"2024-01-05T09:16:03.2162155+00:00"}"
I have also tried to add an application_id filter (with an application that is within my Tenant), but it still does not work.
Am I doing something wrong ?
Here is the code that I have used:
import os
import sys
import grpc
from chirpstack_api import api
server = "...:8080"
api_token = "..."
channel = grpc.insecure_channel(server)
def get_gw_list():
client = api.GatewayServiceStub(channel)
auth_token = [("authorization", "Bearer %s" % api_token)]
req = api.ListGatewaysRequest()
req.tenant_id = '00000000-0000-0000-0000-000000000009'
req.limit = 1000
resp = client.List(req, metadata=auth_token)
return resp
def get_devices_list():
client = api.GatewayServiceStub(channel)
auth_token = [("authorization", "Bearer %s" % api_token)]
req = api.ListDevicesRequest()
req.application_id = '00000000-0000-0000-0000-000000000071'
req.limit = 1000
resp = client.List(req, metadata=auth_token)
return resp
get_devices_list()
Thank you in advance.