Fix error management in oauth handlers

This commit is contained in:
Laurent Destailleur
2026-02-25 19:38:55 +01:00
parent bde08e0868
commit 2796ffa9af
8 changed files with 98 additions and 38 deletions

View File

@@ -98,9 +98,16 @@ if ($action != 'delete' && empty($requestedpermissionsarray)) {
//var_dump($requestedpermissionsarray);exit;
// Instantiate the Api service using the credentials, http client and storage mechanism for the token
$apiService = $serviceFactory->createService('GitHub', $credentials, $storage, $requestedpermissionsarray);
'@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; // createService is only ServiceInterface
$apiService = null;
$nameofservice = 'GitHub';
try {
//$nameofservice = ucfirst(strtolower($genericstring));
$apiService = $serviceFactory->createService($nameofservice, $credentials, $storage, $requestedpermissionsarray);
'@phan-var-force OAuth\OAuth2\Service\AbstractService|OAuth\OAuth1\Service\AbstractService $apiService'; // createService is only ServiceInterface
} catch (Exception $e) {
print 'Error, failed to create service for provider '.$nameofservice.($keyforprovider ? '-'.$keyforprovider : '').'. Message was: '.$e->getMessage();
exit;
}
// access type needed to have oauth provider refreshing token
//$apiService->setAccessType('offline');