Continuing the discussion from OAuth client Error:
I am now attempting to create a new customer using both curl and http, I have issues with both.
1. CURL
I have successfully created an oAuth token, now trying to create a new customer:
Create oAuth Client
Use Access token in header
curl -X POST -H "Authorization: Bearer d91xxxxxxxxefd" -d name='Neighbour' -d type=installed -d organization=neighbour https://api.particle.io/v1/clients
response
{
"ok": true,
"client": {
"name": "Neighbour",
"type": "installed",
"id": "neighbour-xxxx",
"secret": "9ddyyyyyyyyyd",
"org_id": "55ccccccc5b"
}
All good here.
Create Customer
I use the Id and secret response from the oAuth client call to create a new customer. For this call I use the same Access Token in the header as in the previous call (that worked OK).
curl -X POST -H "Authorization: Bearer d91xxxxxxxxefd" -d email=user@mail.com -d no_password=true https://api.particle.io/v1/orgs/particle/customers -u neighbour-xxxx:9ddyyyyyyyyyd
{
"ok": false,
"error": "Organization not found."
}
This is using the exact same access token I used to create the oauth client in the first place - so why the organisation not found for this call but fine for the oauth client call?
For anyone viewing this thread, the example in the docs:
https://docs.particle.io/guide/how-to-build-a-product/authentication/#3-create-a-customer
does not mention how/where to use the oauth credentials. (curl -u client-id-1234:secret).
2. Http
I still set the access token in the Header
headers: {"Authorization" => "Bearer xxxxxxxx"}}
then call
HTTParty.post("https://api.particle.io/v1/orgs/neighbour/customers",
{
:body => [ { "email" => "user@mail.com", "no_password" => "true" } ].to_json,
:basic_auth => { :username => "neighbour-xxx", :password =>
"9ddyyyyyyyyyd" },
:headers => { 'Content-Type' => 'application/json' }
})
Response:
parsed_response={"ok"=>false, "code"=>400, "error"=>"email was empty"}
Is this really a no email problem?
Is the API code available in github to view?
Can anyone spot issues with either or both of these attempts?
thank you.