1
0
Files
breadcrumb-the-shire/modules/helpdesk/lib/Module/Helpdesk/Service/HelpdeskOAuthTokenService.php

42 lines
1.2 KiB
PHP
Raw Normal View History

<?php
namespace MintyPHP\Module\Helpdesk\Service;
/**
* OAuth2 client_credentials token service for BC OData access.
*
* This is a skeleton for V1. Basic Auth is the default and recommended
* auth mode. OAuth2 support can be activated in settings but the full
* token flow (request, cache, refresh) is deferred to a future version.
*/
class HelpdeskOAuthTokenService
{
public function __construct(
private readonly HelpdeskSettingsGateway $settingsGateway,
private readonly HelpdeskTokenRepository $tokenRepository
) {
}
/**
* Get a valid access token for BC API calls.
*
* @return string|null The bearer token, or null if unavailable.
*/
public function getAccessToken(int $tenantId): ?string
{
if ($this->settingsGateway->getAuthMode() !== HelpdeskSettingsGateway::AUTH_MODE_OAUTH2) {
return null;
}
// Check cache first
$cached = $this->tokenRepository->findValidToken($tenantId);
if ($cached !== null) {
return $cached;
}
// Token request would go here in a future version.
// For V1, return null to indicate OAuth2 is not yet fully implemented.
return null;
}
}