Authentication
Token can be obtained from the ActiveCollab interface, or programmatically, using /issue-token command. To demonstrate, lets create a new user account with a known password:
Response: HTTP 200, application/json (Hide)
POST /users
Payload:
1 2 3 4 5
{
"type": "Member",
"email": "member@activecollab.com",
"password": "Easy to remember, hard to guess"
}Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
{
"single": {
"id": 2,
"class": "Member",
"url_path": "\/users\/2",
"is_archived": false,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430163964,
"created_by_id": 1,
"updated_on": 1430163964,
"updated_by_id": 1,
"language_id": 0,
"first_name": "Member",
"last_name": null,
"display_name": "member",
"short_display_name": "member",
"email": "member@activecollab.com",
"additional_email_addresses": [],
"is_pending_activation": false,
"avatar_url": "http:\/\/feather.dev\/proxy.php?proxy=avatar&module=system&v=current&b=DEV&user_id=2&size=--SIZE--×tamp=1430163964",
"custom_permissions": [],
"company_id": 0,
"title": null,
"phone": null,
"im_type": null,
"im_handle": null,
"note": null
}
}Now, lets issue a token:
Response: HTTP 200, application/json (Hide)
POST /issue-token
Payload:
1 2 3 4 5 6
{
"username": "member@activecollab.com",
"password": "Easy to remember, hard to guess",
"client_name": "My Awesome App",
"client_vendor": "ACME Inc"
}Response:
1 2 3 4
{
"is_ok": true,
"token": "2-6zmW8dnKpHqPLwVk2f3LMrTfVxAiJU1DibofeCPt"
}That's it, we just got a token that we can store and reuse to authenticate this user in future requests. In case of error, ActiveCollab will return error dump:
Response: HTTP 500, application/json (Hide)
POST /issue-token
Payload:
1 2 3 4 5 6
{
"username": "member@activecollab.com",
"password": "Invalid Password",
"client_name": "My Awesome App",
"client_vendor": "ACME Inc"
}Response:
1 2 3 4 5 6 7 8 9
{
"type": "ApiSubscriptionError",
"message": "Invalid password",
"file": "\/var\/www\/angie.back\/frameworks\/authentication\/models\/api_subscriptions\/FwApiSubscriptions.class.php",
"line": 101,
"trace": "#0 \/var\/www\/angie.back\/frameworks\/authentication\/controllers\/FwUserSessionController.class.php(71): FwApiSubscriptions::subscribe('member@activeco...', 'Invalid Passwor...', 'My Awesome App', 'ACME Inc', false)\n#1 \/var\/www\/angie.back\/src\/Angie\/Controller.php(42): FwUserSessionController->issue_token(Object(Owner))\n#2 \/var\/www\/angie.back\/classes\/application\/AngieApplicationAdapter.class.php(243): Angie\\Controller->executeAction('issue_token')\n#3 \/var\/www\/angie.back\/classes\/application\/AngieApplication.class.php(839): AngieApplicationAdapter->handleHttpRequest('issue-token', '')\n#4 \/var\/www\/activecollab.back\/instance\/public\/api.php(19): AngieApplication::handleHttpRequest()\n#5 {main}",
"previous": null,
"code": 3
}Response: HTTP 500, application/json (Hide)
POST /issue-token
Payload:
1 2 3 4 5 6
{
"username": "unknown-user@activecollab.com",
"password": "Easy to remember, hard to guess",
"client_name": "My Awesome App",
"client_vendor": "ACME Inc"
}Response:
1 2 3 4 5 6 7 8 9
{
"type": "ApiSubscriptionError",
"message": "User does not exist",
"file": "\/var\/www\/angie.back\/frameworks\/authentication\/models\/api_subscriptions\/FwApiSubscriptions.class.php",
"line": 104,
"trace": "#0 \/var\/www\/angie.back\/frameworks\/authentication\/controllers\/FwUserSessionController.class.php(71): FwApiSubscriptions::subscribe('unknown-user@ac...', 'Easy to remembe...', 'My Awesome App', 'ACME Inc', false)\n#1 \/var\/www\/angie.back\/src\/Angie\/Controller.php(42): FwUserSessionController->issue_token(Object(Owner))\n#2 \/var\/www\/angie.back\/classes\/application\/AngieApplicationAdapter.class.php(243): Angie\\Controller->executeAction('issue_token')\n#3 \/var\/www\/angie.back\/classes\/application\/AngieApplication.class.php(839): AngieApplicationAdapter->handleHttpRequest('issue-token', '')\n#4 \/var\/www\/activecollab.back\/instance\/public\/api.php(19): AngieApplication::handleHttpRequest()\n#5 {main}",
"previous": null,
"code": 2
}Response: HTTP 200, application/json (Hide)
PUT /move-to-archive/user/2
Response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
{
"single": {
"id": 2,
"class": "Member",
"url_path": "\/users\/2",
"is_archived": true,
"is_trashed": false,
"trashed_on": null,
"trashed_by_id": 0,
"created_on": 1430163964,
"created_by_id": 1,
"updated_on": 1430163965,
"updated_by_id": 1,
"language_id": 0,
"first_name": "Member",
"last_name": null,
"display_name": "member",
"short_display_name": "member",
"email": "member@activecollab.com",
"additional_email_addresses": [],
"is_pending_activation": false,
"avatar_url": "http:\/\/feather.dev\/proxy.php?proxy=avatar&module=system&v=current&b=DEV&user_id=2&size=--SIZE--×tamp=1430163965",
"custom_permissions": [],
"company_id": 0,
"title": null,
"phone": null,
"im_type": null,
"im_handle": null,
"note": null
}
}Response: HTTP 500, application/json (Hide)
POST /issue-token
Payload:
1 2 3 4 5 6
{
"username": "member@activecollab.com",
"password": "Easy to remember, hard to guess",
"client_name": "My Awesome App",
"client_vendor": "ACME Inc"
}Response:
1 2 3 4 5 6 7 8 9
{
"type": "ApiSubscriptionError",
"message": "User does not exist",
"file": "\/var\/www\/angie.back\/frameworks\/authentication\/models\/api_subscriptions\/FwApiSubscriptions.class.php",
"line": 104,
"trace": "#0 \/var\/www\/angie.back\/frameworks\/authentication\/controllers\/FwUserSessionController.class.php(71): FwApiSubscriptions::subscribe('member@activeco...', 'Easy to remembe...', 'My Awesome App', 'ACME Inc', false)\n#1 \/var\/www\/angie.back\/src\/Angie\/Controller.php(42): FwUserSessionController->issue_token(Object(Owner))\n#2 \/var\/www\/angie.back\/classes\/application\/AngieApplicationAdapter.class.php(243): Angie\\Controller->executeAction('issue_token')\n#3 \/var\/www\/angie.back\/classes\/application\/AngieApplication.class.php(839): AngieApplicationAdapter->handleHttpRequest('issue-token', '')\n#4 \/var\/www\/activecollab.back\/instance\/public\/api.php(19): AngieApplication::handleHttpRequest()\n#5 {main}",
"previous": null,
"code": 2
}Following error codes are provided:
0- Operation failed (general error),1- Information about client application is not set,2- User does not exist or not active,3- Password is not valid,4- Issue token not allowed for the user.