Device registration using 2-legged Auth Example?

I’ve solved most of my technical issues, but now I’m on to the hard part: Registering new devices for new customers.
I’ve read the guide here (https://docs.particle.io/guide/how-to-build-a-product/authentication/#two-legged-authentication) many times, and there is just a lot missing (or out of date).

I need to figure out how to have a new device claimed, a customer created, etc. Under the “Add credentials to your server” section it says “Coming soon: example implementation of client credentials” so that’s not all that useful. :slight_smile:

I have the 2-legged auth credentials created via the Console for my app. What I’d like to see is a step-by-step or a tutorial on:

  1. User gets a device
  2. How does my App register the new device
  3. How does device get claimed/provisioned
  4. etc.

This is all very unclear in the documentation. The docs say that I need to create an ‘organization’ but in order to do THAT I need to upgrade to a paid account. I’d rather not do that until I’m ready to go live.

Help!

Everything should be available for free up to 25 devices/product. Or did I miss something?

Ok, so then how is that done? I can’t find documentation on that.

Have a look: https://docs.particle.io/guide/tools-and-features/console/

Thanks, I’m aware of that page. But it doesn’t give ANY details on HOW any of that is done. It’s a really general overview with no implementation specifics.

I’ve got my product defined, I’ve built the firmware for it. I can deploy that firmware to devices that I add by hand via the console. Devices that I configure get the proper firmware, and then begin logging data, and I can display that data in my web front-end from my server. But I am still adding ‘customers’ and devices by hand. Clearly that won’t scale. I need customers to be able to sign up on my server – create a customer account – and then set up their device and have it download the firmware, etc. and begin sending their data to my server. That’s what 2-legged authentication is supposed to be for. But I can find no actual examples of how to implement it.

Thanks!

Though it’s true that there doesn’t appear to be a step-by-step tutorial, the docs do a rather good job of explaining how everything is supposed to work, step-by-step. If you follow those guides, and take it one step at a time, you should be able to work it out.

This should give you the information needed on setting up the device:
https://docs.particle.io/guide/how-to-build-a-product/authentication/#device-setup-steps-4-5-amp-6-

https://docs.particle.io/reference/api/#create-a-claim-code

Try downloading the PHoton setup file and have a look to see how Particle does it (as far as claiming goes): https://setup.particle.io

If there are any specifics you’re stuck at, feel free to ask, but writing a full step-by-step tutorial might not be viable time-wise at the moment.

Pardon me for being a bit grumpy about this, but seriously?? Particle can’t be bothered to provide actual implementation details for something that is absolutely fundamental to being able to build an actual product?? Really??

This whole idea, that of making a Photon, or Electron, the basis for an actual product is fundamental to their business model. So having developers be able to create a product, and have their customers/users easily and effortlessly set it up, is a pretty basic part of that.

https://docs.particle.io/guide/how-to-build-a-product/authentication/#device-setup-steps-4-5-amp-6-

That doc assumes you already have your server set up, and have completed the steps prior to it:

https://docs.particle.io/guide/how-to-build-a-product/authentication/#2-add-oauth-credentials-to-your-server

Which is the hand-waving step that states “Coming soon: example implementation of client credentials” That bit there seems like it’s pretty important. Far too important to just gloss over with a “coming soon” banner.

Further down, we get told how to create a customer:
curl -X POST -u “client-id-goes-here:client-secret-goes-here” -d email=abu@agrabahmonkeys.com
-d no_password=true https://api.particle.io/v1/orgs/particle/customers
But that requires an ‘organization’ which, of course, I don’t have, and can’t create. And

curl -X POST -u “my-client-id:my-secret” -d email=foo.bar@davidgs.com -d no_password=true -d access_token=“myAccessToken” https://api.particle.io/v1/mBox/customers
returns:
{“ok”:false,“error”:“Not Found”}

Probably because I don’t have an ‘org’ in my URL, but creating an organization is completely opaque. I can find absolutely zero documentation on it anywhere.

So yeah, I’m frustrated. The docs are falling way short at this point.

Oh, and I did download the Photon Setup file. It’s 55k lines long. I’m thinking digging through that is going to take some time. WAAAAY more time than it would take Particle to actually document how to do this stuff.

You must have misunderstood me, since what I said was: at the moment, there might be other priorities. Given that the process is laid out relatively well, time is better spent elsewhere than on making a start-to-finish example. That’s my take on the matter, but I’m not speaking on behalf of Particle, so don’t blame them for my interpretations, please.

As far as the whole ‘organization’ thing goes, it seems that’s a remnant left behind of the time where you could create actual ‘organizations’ in the console. Nowadays, it’s the product ID that you need, which it does mention in the Cloud API section:
https://docs.particle.io/reference/api/#create-a-customer---client-credentials

The Photon setup file was a suggestion since that was the ‘easiest’ thing I could think of that you could use to test with. if you change the “claim_code” (using search), you should be able to claim the device to your newly made account without having to make a custom solution to begin with.

I gave it a shot myself, having never tried it before, and by using the docs I got 99% there, so it should be doable alright. The last bit was helped out by @rickkas7, after which he pointed me towards a sweet guide he wrote on the topic. Might just suit your request for a tutorial: https://github.com/rickkas7/particle_notes/tree/master/manual-photon-claiming

1 Like