Particle user's access token?

How do I get one for my two-legged authentication of the following:

curl -X POST -H “Authorization: Bearer 1234” -d name=MyApp -d type=installed
-d organization=my-org https://api.particle.io/v1/clients

Do I need to create my own organization first and pay Particle $50/month. I am still in the evaluation stage.

Thanks.

Have you read any of the threads found via forum search for two legged?
https://community.particle.io/search?q=two%20legged
Or the docs
https://docs.particle.io/reference/javascript/#user-management

No useful info in any of them threads?

The documentation is sadly not that great on oauth


https://docs.particle.io/guide/how-to-build-a-product/authentication/

Soon (Late August 2015) you will be able to go to the Particle dashboard and click “Create app” to create a client ID and secret.

Oof, old docs! Actually I think @jeiden is working on the oauth GUI soon, sorry those docs are so outdated!

Thanks,
David

Thanks. It will be very helpful if someone can write step by step procedure in details. One question I have is do I need to have an origination and pay $55 per month just to test the two legged authentication. Can someone answer this. Or can we have the test parameter for “test organization.?”

Hi @mtun009,

Good question! Actually there’s a great guide on oAuth here:

https://docs.particle.io/guide/how-to-build-a-product/authentication/#oauth

and api reference documentation here:

https://docs.particle.io/reference/api/#create-an-oauth-client

You don’t need an org to test this, but you’ll need it if you’re creating customer-tokens / customer-accounts for your users’ devices.

Thanks!
David

Hi Dave-Thanks. I did the following two steps:

  1. curl https://api.particle.io/oauth/token -u particle:particle -d grant_type=password -d username=my_particle_user_name -d password=myparticle_acct_password
    response:

{
“token_type”: “bearer”,
“access_token”: “xxxxxxxxxxxxxxxxxxxx1”,
“expires_in”: 7776000,
“refresh_token”: “xxxxxxxxxxxxxxxxxxxx2”
}

  1. curl -d name=MtApp -d type=installed -d access_token= xxxxxxxxxxxxxxxxxxxx1 https://api.particle.io/v1/clients

response:

{
“ok”: false,
“errors”: [
“Organization not found for user’s role”
]
}

Does this mean I have to pay $55 per month even in our development and evaluation phase?

Thanks.

Hey @mtun009,

Jeff here, one of the Particle engineers. A few things here:

  • We’re working on a new UI in the Particle Dashboard for creating OAuth clients that should be available within 2 weeks. For now, you can still hit the API directly
  • You don’t need to have an organization to create an OAuth client. You can create one just for your user. Check out the reference docs on creating OAuth clients. You just wouldn’t include an organization slug in the POST request. However, if you are planning on building a Particle-powered product that you’d like to manage as a fleet, I would suggest creating an organization and creating OAuth clients for that organization. There is currently a 30-day trial period with the option to cancel anytime. You can always cancel your subscription, and your organization and its clients will still continue to function
  • We are in the process of thinking through refactoring our pricing to allow you to create products and organizations without having to pay (up to a certain number of devices). Stay tuned for updates on that

Hope this helps,

Jeff

1 Like

hi @jeiden,

Thanks. I can create clientId and sercret but when I try to create customer I got errors. I did the following two steps:

curl -d name=MtApp -d type=installed -d access_token= xxxxxx1111 https://api.particle.io/v1/clients

Response:

{
“ok”: true,
“client”: {
“name”: “MtApp”,
“type”: “installed”,
“id”: “mtapp-597”,
“secret”: “serectxxxxxx1111”
}
}

  1. create customer

this format from document:

curl -u my-org-client-1234:long-secret -d grant_type=client_credentials -d scope=customer=jane@example.com https://api.particle.io/oauth/token

what I use:
curl -u mtapp-597:serectxxxxxx1111 -d grant_type=client_credentials -d scope=customer=jane@example.com https://api.particle.io/oauth/token
response:
{
“error”: “invalid_client”,
“error_description”: “Invalid or missing client_id parameter”
}

I am sure I am using the parameters in wrong place. the is no specific on the documents either.

Thanks.

Hi @mtun009,

When registering a customer for an org, you should be hitting your org customer endpoint:

POST to -> api.particle.io/v1/orgs/YOUR_ORG_SLUG/customers

email: "customer-email",
password: "customer-password",
client_id: "your_org_oauth_client_name",
client_secret: "your_oauth_client_secret"

Thanks,
David

1 Like

@dave,

my question is when I use the format below I get the invalid_client error:

curl -u client-id:client-secret -d grant_type=client_credentials -d scope=customer=customer@customer.com https://api.particle.io/oauth/token

this is from Generate a customer scope access token of the document https://docs.particle.io/reference/api/#customers

Please let me know what am I doing wrong. I don’t have my organization registered and I was told I did not need one to test.

Thanks.

Hi @mtun009,

Ahh, I think I’m understanding now. Organizations are a container for customer user accounts and products. You cannot register ‘customer’ accounts without an organization, you can certainly use your non-org oauth account to register normal new ‘user’ accounts, but they won’t be tied to you / your account at all.

You can also register an org for a month for free I believe, if you just want to test.

Thanks!
David