Can't get Spark api working [SOLVED]

Documentation is confusing

Can’t get access token


I am sending same data to POST, but get 400 response

So I’ve taken access_token and valid device id from GUI, still failing: now 404

Same as in docs

What is wrong?

Can you make Documentation more clear about POST headers required?

Hi @ryotsuke,

In the photos it shows you are sending your password as “password” is that correct?

Make sure you check your device’s endpoint: and make sure your function is properly exposed as a function. It’s possible you flashed firmware with this but it didn’t flash properly.


I wouldn’t post real password on screenshot )

Using endpoint url in broswer works:

Should access token be in GET request part?

After reflashing core it started working, so 2nd question was about non-flashed firmware

So now only question #1 remains - how do I get token with POST request?

Ah, awesome! :smile:

Access token should be in the url for GET requests, and in the body for POST requests. I think you were hitting this endpoint already, but zachary posted about the oauth endpoint here:

I have a wrapper for this endpoint in node that I’m using for the command line interface, it looks something like…

var request = require('request');
        uri: "",
        method: "POST",
        form: {
            username: user,
            password: pass,
            grant_type: 'password',
            client_id: client_id,
            client_secret: "client_secret_here"
        json: true
    }, function (error, response, body) {
        if (body && body.access_token) {
            console.log("Got an access token! " + body.access_token);

Hope that helps!

what is client_id here and client_secret?

I basically have a very simple webpage with jquery sending all this stuff like this

I’ve changed URL to intead of (Docs are wrong?)
Still failing:

Ahh typo, my bad, “v1” shouldn’t be in the oauth login url.

cleint_id, and client_secret would normally be per-user approved clients and secrets generated from the API, but for the sake of getting everyone up and running quickly, we’ve left those open ended for the moment, so they can be whatever you like right now.


Typo or not it is not working in both cases :-/

Also how can firmware not be flashed? I have no error messages, nothing weird happening on core.
I’ve added one more Spark function and flashed 2 times already - function is not appearing. Core is not hang - old functions are working.

This way cloud software looks highly unreliable

Can Spark function 404 if something is wrong in this particular function?
UPD: function itself work ok

Every Spark function works except “servo” one. Can’t see an issue
Also it is not exposed to url

Hi @ryotsuke,

Oh! I didn’t realize you had a bunch of other working functions, that makes a big difference! Right now Spark.function is limited to 4 functions so that more ram is available. That’s mentioned in the docs here:

I’m thinking we need to make this a #define so that people can add extra functions more easily. I’ll enter a bug for that.