diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php
index d2a904fecf8..23ccea552e1 100644
--- a/htdocs/admin/emailcollector_card.php
+++ b/htdocs/admin/emailcollector_card.php
@@ -448,8 +448,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// We have to save the token because Google give it only once
$refreshtoken = $tokenobj->getRefreshToken();
+
//var_dump($tokenobj);
- $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ try {
+ $tokenobj = $apiService->refreshAccessToken($tokenobj);
+ } catch (Exception $e) {
+ throw new Exception("Failed to refresh access token: ".$e->getMessage());
+ }
$tokenobj->setRefreshToken($refreshtoken);
$storage->storeAccessToken($OAUTH_SERVICENAME, $tokenobj);
@@ -496,6 +501,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'authentication' => "login",
]);
}
+
if (!$error) {
try {
// To emulate the command connect, you can run
@@ -571,7 +577,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtml .= 'id.'&action=scan&token='.newToken().'">'.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").'';
}
- $morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver);
+ $morehtml .= $form->textwithpicto('', 'Connect string = '.$connectstringserver.'
Option MAIN_IMAP_USE_PHPIMAP = '.getDolGlobalInt('MAIN_IMAP_USE_PHPIMAP'));
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref.'