Hi, I’m trying to use the gRPC API in Python, but no matter what I try, I keep getting a grpc_status:16
, status = StatusCode.UNAUTHENTICATED
. Below is my MWE:
import grpc
from chirpstack_api import API
def main():
target = "my.chirpstack.com:8000"
server_token = "<TOKEN-FROM-CONFIG>"
api_token = "<TOKEN-FROM-WEB-UI>"
auth_token = [("authorization", f"Bearer {api_token}")]
channel = grpc.insecure_channel(target)
gateway_stub = api.GatewayServiceStub(channel)
request = api.ListGatewaysRequest()
response = gateway_stub.List(request, metadata=auth_token)
# error on the line above
for gateway in response.gateways:
print(f"Gateway ID: {gateway.id}, EUI: {gateway.eui}")
if __name__ == "__main__":
main()
When I use the server_token
, I get grpc_message:"InvalidToken"
, when I use the api_token
, I get grpc_message:""
.
In both cases, I get the following in my server logs:
INFO gRPC{uri=/api.GatewayService/List}: chirpstack::api: Finished processing request status="200"
In the [api]
section of the config, I have set the port to 8000
.
What’s going on there? Why can’t I authenticate successfully? And why do the logs indicate a success regardless?