MicroGateway Losant API Token Length Problem

I have successfully setup the Losant version of the WiFi MicroGateway before with no problems. However when It ried to set it up again this morning on a new gateway I ran into an issue. After connecting to wifi, the device would connect, register itself as a Device and then start throwing errors in Losant.


The API Token generated by Losant is quite long, around 252 characters, and according to some forum posts, this can vary.

The web form for configuring the MicroGateway has a size attribute of 50. This leads me to believe that the API Token might somehow be getting truncated and causing the issues seen on the Losant side?

I tried to flash the Gateway to the newest version of Losant, but after doing so, the value is still 50.
I tried changing the size value to 255, and then submitting the form, on the off chance that it would send the whole string, but that did not change the result.

I am following this document, which has worked before but doesn’t seem to be working now?

Post on length of token from Losant:

Any thoughts?

Adding screenshot of gateway creating itself:

So the size attribute of the application token input element does not really limit the input length. It just sets the visible size of the text in the input. If you watch the network tab when you click save settings you will see the full application token is sent to the back end.

That said previously the application token variable was limited to 238 characters. I increased it’s limit to 1024. However if your application token is really long it may cause failures for HTTP REST API calls to Losant to create the Gateway and to create the children devices. This is a small processor and it can only handle so much data in an HTTP POST request. That Application Token must go in the Authorization header of the Post request so please keep it as short as you can.

The firmware has been updated to allow longer Application Tokens. let me know what you find.

Thanks Travis! I will re-flash and try again.
The length seems to be determined by Losant.
I just click ‘Create Application Token’ and it gives me the ability to Copy what it generated or Download to a file. I don’t have the ability to change or edit its length.

I generated a new one just now, and it looks to be 252 characters.

From what I can tell the length seems to be dependent on some rules. This is based on Julia’s comment on that forum post here:

You are absolutely correct, this is my mistake. I started playing around with them just now and was able to get an Application Token with Custom permissions to 3,273 characters (by setting 100 scopes). It seems that “all permissions,” “read only,” and “custom” all have their own length, and the custom setting varies depending on your number of scopes. I am not sure that “all permissions” and “read only” have static or maximum lengths, but I will keep testing.

Thanks so much for pointing this out! :smile: