Oauth using particle:particle with a legacy account

Hi,

We could use some advice on the Authorization process for using the API. We would like to find a process that works with both older "legacy" accounts and with new Particle accounts.

What works:

Create a new account. Get a token with client ID / client secret of particle:particle

curl ``https://api.particle.io/oauth/token``
-u particle:particle
-d grant_type=password
-d "``username=newaccount@ourdomain.com``"
-d "password=<yourpasswordhere>"

{"token_type":"bearer","access_token":"ffffffff897cc2b320002ddd50000c86145346a8","expires_in":7776000,"refresh_token":"ffffffffa6d1ddd00015b0e95670000d18d2b53a"}

What fails:

Using the same technique on a legacy account fails.

curl ``https://api.particle.io/oauth/token``
-u particle:particle
-d grant_type=password
-d "``username=legacyaccount@ourdomain.com``"
-d "password=<yourpasswordhere>"

{"error":"invalid_grant","error_description":"User credentials are invalid"}

Is there a way to obtain an access token without having to create a client ID / client secret in a legacy account?

That should work. What I use is slightly different and is at least worth a try to see if it makes a difference for you:

postData = {
  'client_id': 'particle',
  'client_secret': 'particle',
  'expires_in': localTokenLength,
  'grant_type': 'password',
  'password': $(passwordInputElem).val(),
  'username': $(usernameInputElem).val()
};
  • Instead of using basic auth (-u), put the client_id and client_secret in the POST body
  • Try using JSON encoding for the POST body instead of URL form encoding

Thanks for the idea. We tried it and it works for one legacy account, but not for another. So, no difference. I’m going to contact Particle Support for advice on this so I can share my username/password.

@Support In this thread I described a problem with obtaining an authorization token for an older account. I have a CURL command that works when I use a new account. My buddy and I each have older personal accounts and the same command works with them. However, our organization has an older account and the CURL command does not work with that one account. It leads us to think that there is something different about that one account. I assume that to troubleshoot this I will have to share our account information. Would someone contact me to help? Thanks.