Understanding all the different tokens


i am still a bit confused about the tokens.

When I call inside the cli particle token list i get severall tokens. Some are expired, one is declared “user”, one is “spark-ide”, one “cloud compile” and a lot are “password_only”.

I am working with the ubidots cloud. To retrieve data from particle to ubidots, a token was not required. But as i want to work the other way around as well and publish data from ubidots to events i need a token. Which token shall i take for this?


I think there already is one misunderstanding. You don’t retrieve data from Particle to Ubidots. You are sending data from the device to Ubidots via their library. That’s why you don’t need the Particle token but Ubidots’ own API Key as you want access their servers from the “outside world”.

The other way round Ubidots (=“outside world” for Partilce) needs to be granted access to their servers, hence you need Particle’s key (aka access token).


but which of all the tokens listed shall i take?

I’d use a password_only token.

BTW, when you want to push data from Ubidots to Particle via an event you need to Particle.subscribe() to that event.

Yes on the particle itself, but i understood it that all events are shown in the devices console without subscribing to any specific event.

I got it to work, so that now the data from ubidots gets to the particle console:

But I dont get the data to my particle board. There are two errors: “error status 400” and “sleeping, too many errors”
Any help on that?

First HTTP error code 400 can be googled and here is a link that explains possible reasons and solutions

And since the targeted server keeps throwing that error the Particle cloud mutes that event to protect itself and also the target server.

Hence the thing you need to do is to get rid of the HTTP and that will then also solve the sleeping webhook problem.

You can go to your integration/webhook definition and scroll all the way down to see more info about the “offending” requests.

Just for debugging the issue you can also try the other access token types.


On the webhook integration it states:

{“code”: 400001, “message”: “The payload sent is not a valid json document.”

I am using the example 5 from https://help.ubidots.com/en/articles/513304-connect-your-particle-device-to-ubidots-using-particle-webhooks

Then it would be good to sanitize the payload you are sending.
Can you show it?


Not exactly. What data are you sending to your target server?

If you cannot find the source of your JSON you could redirect your webhook to a service like requestbin.com and see what it receives.

However, your request length is only mentioned as 3 bytes which cannot be a valid JSON of any useful kind :wink:

Alright, i will try requestbin,

So i am just implementing the example https://help.ubidots.com/en/articles/513304-connect-your-particle-device-to-ubidots-using-particle-webhooks
I have a raw variable in ubidots which is connected to a widget switch. I then created an event which gets called when the value from the variable changes to 1 -> switch is turned on. And this is the action the ubidots event triggers:

what i still dont fully understand.
The data is shown in the particle console in the events.

so the data has been published, right? Sorry for the confusion about the whole particle/ubidots/webhook world

It seems your outgoing (from device to the webhook manager) event is not valid.
Your screenshot above only shows how you instructed Ubidots to send data to Particle.

Your data is shown but it’s not valid JSON.

A valid JSON would look like this

{ "value": 1.0 }

(of course "value" should be the key that you’ve used on the Ubidots side to store the data in)

I understand what u are saying.
I am still stuck on fully understanding the whole framework i think.
My understanding was: I am using the particle board with the ubidots library. THis makes it easier to push data directly to ubidots. For that i also need a webhook configured to ubidots. So in my understanding data is still going through the particle cloud?

As now i want to send data from ubidots to my particle board i was looking at the example shown on the particle tutorials https://help.ubidots.com/en/articles/513304-connect-your-particle-device-to-ubidots-using-particle-webhooks .
So when clicking a button on the ubidots dashboard i am publishing to an event to the particle cloud, right? On this event i can then subscribe from the particle board.

I am just implementing the very easy tutorial example on that, but apparently this is not sending proper json style

Can you post your code?

Now i am a bit confused.
Maybe this will clear things:
I thought that with the ubidots webhook i was sending data to particle cloud. and from there i would grab it with a subscription to my device. So to check if the first step works, i was just sending the data from ubidots to particle without any device in use.

Particle integrations/webhooks are a means for Particle devices to request data from a remote server. Just like a normal hook goes in one direction and then turns round to come back.
If it would be going one way straight it would hardly be a hook :wink:

Particle.publish() (events) would be a one-way thing - pushing data to some remote endpoint.