What is use of -u particle:particle when generating a oauth token in spark server

Here is the documentation of spark cloud server.


POST /oauth/token

# Using curl in your terminal
curl https://api.particle.io/oauth/token -u particle:particle \
     -d grant_type=password -d username=joe@example.com -d password=SuperSecret

in this API, we have to pass the username and password ( -d username -d password )to grant oauth code, but at the same time why do we also need to pass -u clientid:client_password, and clientid can be anything.

I don’t understand why pass clientid and client_password as well, what is the use of them, in particular the client password?

1 Like

It should be -u particle:particle

Reply from @zachary to the same question of mine months back:

It's a requirement of OAuth, made simple by us. An OAuth 2.0 access token can only be requested by an authenticated client. The client credentials are passed in HTTP Basic Auth with the `-u` flag. Haven't created a client? That's OK, just pass `-u particle:particle` and you don't have to.
1 Like

Thanks Kenneth. Also, the broader point is OAuth2 compatibility. You can use grant types other than password, like the full authorization code grant flow used when you authorize the IFTTT channel. In order to do so you need to create and client ID and secret with a call to POST /v1/clients. The API is fully there, but the documentation will be improved in the coming months. We’ll also build a UI for managing your clients and tokens. This will be especially important for organizations with products and apps to control those products.

1 Like