Device Information within Products

I am starting to use the product tools for our devices (all Electrons), and I have a question on how I should access my devices from my backend server.

My question is, what is the “right” way to access information regarding a device based solely on its ID? What I’d like to do is send the request /devices/:deviceID and get back info on the device.

It seems that in order for this request to return the correct result, the access_token needs to match the owner of the device. Devices that don’t have owners won’t be returned using this endpoint.

On authorization – I am generating an access token from the /oauth/token endpoint successfully for a client I’ve created. My client has full permissions. I’ve also tried my personal account access token, but this does not function either.

I can successfully access the device via /products/:productID/devices/:deviceID using the access token generated by the client.

My assumption right now is that when a device is ownerless, you can only access through the product endpoint. Is that correct?

Ideally there would be a way to get a token that can access a device within our organization across different products / with different owners.

My question is, what is the “right” way to access information regarding a device based solely on its ID? What I’d like to do is send the request /devices/:deviceID and get back info on the device.

The device ID is a good, unique identifier. Since many APIs use the device ID already, it's a logical choice.

It seems that in order for this request to return the correct result, the access_token needs to match the owner of the device. Devices that don’t have owners won’t be returned using this endpoint.

If the device is a product device, you can use the product device endpoint:

GET /v1/products/<PRODUCT_ID>/devices/<DEVICE_ID>

This requires a product bearer token but works regardless of who claimed the device.

It's best to not use the individual device endpoints with products unless you claim all of the devices to a single account since you'd need to create a customer impersonation token for that user. In some cases you may have no choice to this this, however, such as when you want to send private events to a device where devices are claimed to many different accounts.

My assumption right now is that when a device is ownerless, you can only access through the product endpoint. Is that correct?

Correct. But we don't recommend using unclaimed product devices because they can be stolen. It's better to claim all of the devices to a single account that you control than leave then unclaimed.

Ideally there would be a way to get a token that can access a device within our organization across different products / with different owners.

There are no tokens that span both product and users. You can have one token per product, but that's as close as you can get.

1 Like

OK, thanks. For now I will just claim all devices to my personal account.

Maybe this could be a feature request – Have the ability to specify a default user on a product?

I can’t see a future where I use this type of “customer is the device owner” relationship. My product requires both the Particle API and my own API for database historical data.