App id via web form to be reflected in TTN Console

When the User Submits form That data should be reflected in TTN Console.

Original topic title - or specification if you will:

“I Have a form in my web application. I need to take Input like appId from User, when he submits that, Then that AppId should be reflected un TTN Console”

So the user enters an App Id.

What do you want to actually happen in the TTN web console - the setup of a new application?

What about devices?

We want to create our own application server which interacts with the TTN based on User Inputs. So, a user will be able to create a new application on my application server, which should internally setup the TTN for receiving data from the devices. Since we will be using ABP on the devices, we wanted to share the keys from our application server to the devices. However, we are not able to understand how to connect the application server to the TTN, through an API. We do not want the user to interact with TTN. CAn you please guide us on how this can be done?

Have you tried this:

https://www.thethingsnetwork.org/docs/applications/manager/

Yes, we went through the details. However, we are not able to understand how to connect to the TTN. When we tried it, we are getting a 401 forbidden error.

401 is usually Unauthorized - have you read that section?

Please can you provide a whole pile more detail so it’s not a “have you tried” - “yes” thread.

Dear Nick,

Thanks for the response and the time taken to help us resolve our issues. We have an IoT network, with LoRa hardware and a gateway that is able to upload data to the TTN Network Server. Thereafter, we used HTTP integrations to push the data to our application server. This sequence of operations work fine. Here, we created the application ID and the device IDs and configured them through the TTN console web interface.

Further to this, we intend to provide the application creation, device creation and their management aspects through forms to our users. These forms will reside in our application server and will save the user entries/requests locally, while also, trying to communicate with the TTN server to perform the required operations in the background. For example, if a user intends to create a new application for a IoT related domain, say smart garbage bins, he will visit our application server, fill in the details (App_ID, Description, APP_EUI and Handler). The form is expected to thereafter send the request to the TTN and create the application on the fly. The response of this operation will be used to save the user details locally into our db, while communiating to the user, success /failure of the operation.

When we try to do this, there are a few doubts and also some places where we are not able to understand how the API integration can happen from our Application Server. Some doubts include:

  1. Since we create applications on TTN through a user login, how can we do this through our web application?
  2. Is it required to create a client id, acess key, API key?
  3. What is the format of commands that have to be sent to create the application? Is there a template that we can directly follow?
  4. Will we need to use HTTP or HTTPs to do these transactions?
  5. Can we use the SDKs to do this?

Please direct us to the right resources or steps so that we can successfully transact with the TTN through our web application.

I feel there is something that we are doing fundamentally wrong, which is not allowing us to communicate.

I’m not sure I understand the road block you’re facing, or more particularly, where it stops working for you. I’ve linked to the Application Manager API that provides an HTTP(S) interface that allows you to CRUD applications & devices.

There is also the ttnctl command line utility that will allow similar things which could be run at the command line of your server in response to a web request.

Hi @mkyadav, I have used the keep-it-simple approach to this type of requirement.

I accept requests such as as “register an application” or “register a device” into a database. Then I extract the request data from the database and use it in pre-written scripts that drive the ttn-lw-cli Command Line Interface (CLI) to interact with the TTN LoRaWAN core.

ttn-lw-cli is a command line utility that interfaces to the gRPC API.

That way I have much easier control, error-checking, etc. and can see a good audit trail.

Dear Nick,

Thanks for the response and sorry for the delay in responding from our side.

When you mention key, do you mean API Key? If so, we do not have this. How can it be generated? Also, wanted to know if the API key will be unique for a client ID or is it application specific?

As you have mentioned, it probably is the key problem that is not allowing us to authenticate.

We intend to use HTTP to connect remotely, not gRPC.

Yes, an API key - the documentation https://www.thethingsnetwork.org/docs/applications/manager/authentication.html will need some prior experience of doing such things. I’ve not had a need yet, so I can’t give you a gift wrapped working sample.

From the docs, it looks like an application key which you can generate in the web console. This looks to be application specific, but you want to create a new application. In that case, following @cultsdotelecomatgmai’s recommendation, scripting the ttnctl utility should allow what you need:

https://www.thethingsnetwork.org/docs/network/cli/quick-start.html

Ok. Nick… Thanks for the help. Will try to work with what you have shared.

We know you have a web server for your form, so you have all you need.

You can install the ttnctl, try things out on the command line and then using whatever web scripting language, call the ttnctl via the usual system call.