I'm logged in to the ActiveCollab API now, and am looking to get a token.
I see the documentation here, but I can't tell what the base URL should be:
https://developers.activecollab.com/api-documentation/v1/authentication.html
I've tried to follow the process described here: Active Collab v5 issue-token API call returns "invalid password" even though password is valid
and here: https://gist.github.com/Elvis339/c66104950d0a7801ef544869786d2c77
But I get this error (added "source" to try to respond to error, but the error is the same without it):
In the end, I'm just trying to use the API to pull info for reporting.
This Steps can get Token by Postman
#1 Create Environment as demo
#2 login URL
POST https://activecollab.com/api/v1/external/login
#3 Setup Scripts
Select Post-response
Scripts
let jsonData = pm.response.json();
// Extract accounts[0].name and save as "account_num"
pm.environment.set("account_num", jsonData.accounts[0].name);
// Save entire user object (as string)
pm.environment.set("user", JSON.stringify(jsonData.user));
// Save just the intent token
pm.environment.set("intent", jsonData.user.intent);
#4 Credential
Select "Body" tab
Select form-data
Enter email
and password
#5 Press Send
button
#6 Get token URL
POST https://app.activecollab.com/{{account_num}}/api/v1/issue-token-intent
Setup Scripts
Select Post-response
Select Scripts
let jsonData = pm.response.json();
// Extract token and save as "token"
pm.environment.set("token", jsonData.token);
#7 set intent
Select "Body" tab
Select x-www-form-urlencoded
Key | Value |
---|---|
intent | {{intent}} |
client_name | AppName |
client_vendor | AppVendor |
#8 Press Send
Button
Example of how to call API
#9 Get Projects API URL
GET https://app.activecollab.com/{{account_num}}/api/v1/projects
Select Headers
tab
Key | Value |
---|---|
X-Angie-AuthApiToken | {{token}} |
#10 Press Send
button
You can get the project list in body
of output
Using node code instead of Postman to minimize typo error.
Save as get-token.js
const axios = require('axios');
const FormData = require('form-data');
const qs = require('qs');
const email = 'your_email_address';
const password = 'your_password';
const client_name = 'LCHY';
const client_vendor = 'Info_Assets';
async function main() {
try {
// Step 1: Login
const loginUrl = 'https://activecollab.com/api/v1/external/login';
const loginForm = new FormData();
loginForm.append('email', email);
loginForm.append('password', password);
const loginRes = await axios.post(loginUrl, loginForm, {
headers: loginForm.getHeaders()
});
const loginData = loginRes.data;
const account_num = loginData.accounts[0].name;
const intent = loginData.user.intent;
console.log('Logged in. Account Num:', account_num);
console.log('Intent Token:', intent);
// Step 2: Get Token
const tokenUrl = `https://app.activecollab.com/${account_num}/api/v1/issue-token-intent`;
const tokenRes = await axios.post(tokenUrl, qs.stringify({
intent,
client_name,
client_vendor
}), {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
const token = tokenRes.data.token;
console.log('Retrieved API Token:', token);
// Step 3: Get Projects
const projectsUrl = `https://app.activecollab.com/${account_num}/api/v1/projects`;
const projectsRes = await axios.get(projectsUrl, {
headers: {
'X-Angie-AuthApiToken': token
}
});
console.log('Projects:', projectsRes.data);
} catch (err) {
console.error('Error:', err.response?.data || err.message);
}
}
main();
Replace your credential
const email = 'your_email_address';
const password = 'your_password';
node -v
v16.16.0
v18,v2x also fine
npm install axios form-data qs
node get-token.js