Cloud API for data_usage question

I created a “mobile app” authentication and a “web app” authentication, both at the account level (not at the product level). I then attempted to look up data_usage for one of my Particle SIMs. The device with this SIM is associated with a product and my authentications are the account level since I have multiple products (one auth to check all sims/products).

My URL was:
https://api.particle.io/v1/sims//data_usage?access_token=

The outcome was:
{“error”:“invalid_token”,“error_description”:“The access token provided is invalid.”}

Should this have worked?
Thanks,
Tim

oAuth credentials created at the user-level do not have access to resources the user has access to. It will only have access to that user’s sandbox.

You need to create oAuth tokens at the product level to grant access to products.

Also you will need to use the product SIM data usage endpoint:

/v1/products/:productIdOrSlug/sims/:iccid/data_usage

You need to use an actual user token (not oAuth or API user) in order to access multiple products in the free tier. Once you are growth or enterprise you can use a organization-level API user for that purpose.

1 Like

I’m okay focusing on a single product and not worrying about a “meta user” or “super user” for the entire sandbox. That said, creating a user authentication with full permissions in the product is not allowing the data_usage API call to work for sims that are also in the same product. Guess I better ask, what is meant by “actual user token”? :slight_smile:

I got it. Using the Particle CLI, command: particle token list. The “user” token works with the API call.
Thanks again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.