Getting access to API 2.0
To retrieve an authorization token for Rest calls, send a POST request to /api/oauth/token with the parameters:
- username
- password
- client_id=frontend
- grant_type=password
Using curl:
curl --data "username=foo&password=bar&client_id=frontend&grant_type=password" https://subdomain.adhese.org/api/oauth/token
You will get back an access token:
{
"access_token": "123456",
"token_type": "bearer",
"expires_in": 42237,
"scope": "read write"
}
To execute Rest requests that require authorization, add an Authorization header with value Bearer <access_token>, where <access_token> is the access_token returned by the above request.
curl -H "Authorization:Bearer <access_token>" https://subdomain.adhese.org/api/...
To test against localhost, use
curl --data "username=admin&password=admin&client_id=frontend&grant_type=password" http://localhost:8080/api/oauth/token
curl --data "username=admin&password=admin&client_id=frontend&grant_type=password" http://localhost:8080/api/oauth/token