Good evening all,
Found that username and password auth just... stopped working.
I've made the below which can work with API keys generated from inside your instance.
`
use ActiveCollab\SDK\Token;
use ActiveCollab\SDK\TokenInterface;
final class ApiKeyTokenFactory {
public static function create(
string $apiBaseUrl,
string $apiKey
): TokenInterface {
return new Token($apiKey, $apiBaseUrl);
}
}
final class ApiKeyAuthenticator {
private string $baseUrl;
private string $apiKey;
public function __construct(string $baseUrl, string $apiKey) {
$this->baseUrl = rtrim($baseUrl, '/');
$this->apiKey = $apiKey;
}
public function issueToken(): TokenInterface {
return ApiKeyTokenFactory::create(
$this->baseUrl,
$this->apiKey
);
}
}
$authenticator = new ApiKeyAuthenticator('https://app.activecollab.com/' . $ac_instance, $ac_apikey);
$token = $authenticator->issueToken();
$ac = new \ActiveCollab\SDK\Client($token);
`
Finally, a change is needed in src/Client.php to change the auth header from X-Angie-AuthApiToken to the below
private function prepareHeaders() { return ['Authorization: Bearer ' . $this->getToken()]; }
Sorry if this is the wrong way to submit something like this - just wanted to give back and to help with possibly updating it?
Many thanks to all involved in the project.
Good evening all,
Found that username and password auth just... stopped working.
I've made the below which can work with API keys generated from inside your instance.
`
use ActiveCollab\SDK\Token;
use ActiveCollab\SDK\TokenInterface;
final class ApiKeyTokenFactory {
public static function create(
string $apiBaseUrl,
string $apiKey
): TokenInterface {
return new Token($apiKey, $apiBaseUrl);
}
}
final class ApiKeyAuthenticator {
private string $baseUrl;
private string $apiKey;
}
$authenticator = new ApiKeyAuthenticator('https://app.activecollab.com/' . $ac_instance, $ac_apikey);
$token = $authenticator->issueToken();
$ac = new \ActiveCollab\SDK\Client($token);
`
Finally, a change is needed in src/Client.php to change the auth header from X-Angie-AuthApiToken to the below
private function prepareHeaders() { return ['Authorization: Bearer ' . $this->getToken()]; }Sorry if this is the wrong way to submit something like this - just wanted to give back and to help with possibly updating it?
Many thanks to all involved in the project.