Set Claim Code Fails (-1)

I’m trying to set the claim code for a photon, and getting an error. The claim code was generated using a token generated with a customer-scope, for a particular product.

POST /set? HTTP/1.1
Content-Type: application/x-www-form-urlencoded

cc=<my claim code here>
    "r": -1

My understanding is that I would generate a code by hitting this endpoint:, and then connect to the device in soft ap mode, and POST to, passing the claim code, like this:

POST /v1/products/<my device here>/device_claims HTTP/1.1
Authorization: Bearer <my customer-scoped token here>

Is that correct?

The device had previously been claimed and then unclaimed.

Normally you use the Photon/P1 Device Setup library instead, but if you want to do it manually I think you’re missing some steps. Also, the parameter to the /set must be in JSON format instead of form-urlencoded.

This page shows how to do it manually:

1 Like

Awesome, thank you for the link! I wasn’t aware of this treasure trove of documentation. Setting the claim code with the body in JSON instead of form-urlencoded now succeeds, (returning 0), but it’s not actually associated with my user. I didn’t know the expiration for claim codes, so I generated a fresh one, and set that, and it still does not show up in the console.

I wasn’t sure if the order of configuring the access point and setting the claim code mattered, so I erased the wifi networks, set the claim code and configured ap, with the same result. Should I do the factory reset described here?

Actually, I got it to work. I was missing the "Import Device into Product" step. It would have taken even longer without your documentation calling it out

It's not obvious from the documentation, but you have to add the device ID to the product before it can be claimed using two-legged auth.

Not obvious indeed.

1 Like