3

I am trying to obtain an API Token via this call:

curl -H "Content-Type: application/json" -X POST -d '{"username": "MY_EMAIL","password": "MY_PWD","client_name": "XXX","client_vendor": "XXX"}' https://app.activecollab.com/MY_ID/api/v1/issue-token

But I am receiving this response even though the password is correct:

{
    "type":"ApiSubscriptionError",
    "message":"Invalid password",
    "code":3
}

I am following the instructions at https://labs.activecollab.com/nightly-activecollab-api/v1/authentication.html

Is anyone able to use the Active Collab v5 API OK? If so, can you help spot the trouble?

Ilija
  • 4,105
  • 4
  • 32
  • 46

2 Answers2

5

Authentication is done in two steps. First one is to authenticate to main authentication service (https://activecollab.com):

curl -XPOST -d 'email=user@example.com&password=******' https://activecollab.com/api/v1/external/login

This call will return a list of accounts that authenticated user has access to, as well as user details:

{
    "is_ok": true,
    "accounts": [
        {
            "class": "FeatherApplicationInstance",
            "display_name": "Company Name (ID: #ACCOUNT_ID#)",
            "name": 1,
            "url": "https://app.activecollab.com/#ACCOUNT_ID#"
        }
    ],
    "user": {
        "avatar_url": "https://activecollab.com/avatars/user_#USER_ID#.png",
        "first_name": "John",
        "last_name": "Doe",
        "intent": "long string"
    }
}

Among user properties there's intent property. It is used to authenticate agains a particular Active Collab 5 accounts, like this:

curl -XPOST -d 'intent=LONG-INTENT-STRING-HERE&client_name=AppName&client_vendor=AppVendor' https://app.activecollab.com/#ACCOUNT_ID#/api/v1/issue-token-intent

Client vendor and client name are names of your organisation, and name of your app. This call will return a token that you can use to make further API calls in that account:

curl -H "X-Angie-AuthApiToken: TOKEN-HERE" https://app.activecollab.com/#ACCOUNT_ID#/api/v1/projects
Ilija
  • 4,105
  • 4
  • 32
  • 46
  • this answer no longer appears to work. I am on a Cloud account, I was able to get an intent string from the first curl request, however the second curl did not work. It returned a 400 error with no further information. I tried mixing in various paramaters and endpoints based on the answer under this one and stuff i saw in the docs. Nothing seems to work. – Francis Yaconiello Jun 15 '17 at 19:54
  • 1
    Hello Fancis. Just tried it out, all three requests, executed in that order work as expected. – Ilija Jun 16 '17 at 10:51
  • I tried it again today and it worked. Not sure why I got a different response though. My bash history shows the exact same curl requests - unless some sort of invisible/bad whitespace character from copying and pasting from stack overflow was causing an issue. – Francis Yaconiello Jun 16 '17 at 13:51
  • @Ilija I tried the above (https://my.activecollab.com/api/v1/external/login ) and gets a response saying I need to "double check my password". But this is the password that I use to login to https://my.activecollab.com/ then choose the project. Please kindly help, what am I doing wrong here. I am testing the request using Postman – Maruti Mohanty Jul 21 '17 at 09:45
  • Credentials pair (address, and password) may be incorrect, or field names may be incorrect. A screenshot with settings would be great to see what's causing the problem. – Ilija Jul 21 '17 at 17:05
  • 2
    Works for me! The token hearder name is not clearly described in the API instructions! – layser Feb 10 '18 at 21:12
3

An activeCollab support person has provided me the info I needed. To get a token for my cloud account, I had to follow different documentation: https://gist.github.com/malizmaj/e04207c7712ba9f65fb7

I was not able to find that documentation on my own via googling.

Would be nice if the documentation at https://labs.activecollab.com/nightly-activecollab-api/v1/authentication.html mentioned it was only for non-cloud accounts!

Anyway, I am now able to make API calls to my cloud account ok!