Calling Particle Auth Api with JSON

Hi All,

Apologies in advance if this info is elsewhere on the forum, could not find through searching, but feel free to delete or close if elsewhere.

I am testing some shadow customer creation for a product in postman and looking for some guidance.

I am trying to create a new user with POST and the following url: https://api.particle.io/v1/products/:productlD/customers

I do not have auth turned on but my JSON looks like this:

{
    "productIdOrSlug": ":productID",
    "client_id": "12345666blahblahblah",
    "email": "test@gmail.com",
    "no_password": "true",
    "response_type": "token"
}

The response I get is this:

{
    "ok": false,
    "error": "Product not found."
}

I’m pretty sure I have a formatting issue of I’m missing something from my JSON, but can’t figure out what it is.

Do you literally have :productID in your URL or do you rather have it replaced with your actual product ID?

1 Like

Sorry @ScruffR,

I have my product ID where :productID exists in my post above, similarly with my client_id

EDIT: actually apologies, I am using my CLIENT_ID as my product ID also. :man_facepalming:

Now, I am getting a invalid scope issue, but I will try solve that.

1 Like

For the scope, make sure you are using the correct auth token as described here.

When sending the data via a JSON POST be sure to set the Content-Type to application/json. I think the default might be URL form encoded.

1 Like

Ok I got this working using Basic Auth and the following JSON.

{
    "productIdOrSlug": ":productID",
    "client_id": "12345666blahblahblah",
    "email": "test@gmail.com",
    "no_password": "true",
    "response_type": "token"
}

However I am getting the following response, but when I check in my product the customer has actually been created.

{
    "error": "invalid_client",
    "error_description": "Missing parameters. \"username\" and \"password\" are required"
}

@rickkas7

Is your most recent reply the answer to the above, should I be using a product bearer token to create shadow customers rather than the client id and secret?