gRPC api and Go

Hello,

I want use gRPC api with Go client but I’m beginner regarding both gRPC and Go, so I need some help to find out the right way to do it…

That’s what I understood:

gRPC server is directly installed with Lora-app-server and all functions (wrote in Go) from client side to interface with gRPC api are already available?

So I have to write a script “main.go for instance” to connect to gRPC server and import package “github.com/brocaar/lora-app-server/api” to use Go client function ???

The following part is not really clear for me:

When using [gRPC](http://grpc.io/), the JWT token needs to be stored in theauthorizationkey of the request metadata. For example in Go, this can be done by the [grpc.WithPerRPCCredentials](https://godoc.org/google.golang.org/grpc#WithPerRPCCredentials) method.

Globally I must store the token and provide it for each request?

So I found some example to connect in Go I will add my example later.

For information as I’m beginner in Go I did Tour of Go :wink: and I read gRPC documentation link then I performed SayHello and SayHelloAgain example, it work.

Thank you for your help!

1 Like

Hi,

Did you ever get anywhere with this?

Hello,

unfortunately not yet, however it’s still in my roadmap.
Currently I’m using MQTT and REST API, but I really want dig into gRPC framework.

1 Like

ok, thanks.

I’m looking to develop a provider for terraform.io so we can add the configuration of loraserver to the deployment automation we use for the rest of our infrastructure.

I’ll keep hunting for more documentation on how to use this.

Matt

Hey @julien @Proffalken ! Any luck regarding how to use LoRa Server gRPC API?

There is some good sample code here:

Note that the sample in question doesn’t cover token expiration or refreshing the token if you are building this into a long-running service. You would want to expand on JWTCredentials for such purpose.

2 Likes

Hi @bconway, Thank you so much for your response!
I actually wanted to know how do we use LoRa Server gRPC API to post/get the data from LoRa App Server to LoRa Network Server?

I am currently using REST API's of LoRa App Server.
To post the data from REST API's to LoRa Network Server , I have made my own API in Go, because I wasn’t able to get a hang of the gRPC API & how it’s working.

So it will be really helpful if you could guide me on the same!

Thank you!

This question is a little unclear. Are you trying to modify the communication between the two? If so, you would need to start digging into the code for each.

If you’re merely trying to use the LoRa (network) Server APIs, you will need to use gRPC, as the network server doesn’t currently expose the gRPC gateway (REST APIs).

1 Like

I ended up starting to write a python library to talk to the API instead: https://github.com/mockingbirdconsulting/pyloraserver

I’ve been busy helping organise thethingsconference.uk for a few months, but that’s complete now so I’ll be moving back to work on this shortly.

1 Like

Yes, exactly! As the LoRa (network) Server APIs, don’t currently expose the gRPC gateway (REST APIs), so how do I post data to LoRa (network) Server API using gRPC only?

See the sample code I linked above. That example is for the application server and not the network server, but it will work similarly with the NS’s proto definitions.

1 Like

Hi @bconway , so if i’m understanding correctly, you’re saying that I have to make a separate Go program to connnect to gRPC first and then send the data to NS proto definitions?