diff --git a/library/TokenUtils.php b/library/TokenUtils.php
index 7a6ebd90846017e60d149f596fba1875cf25b6bb..8552514794e1d306864fbd93aab825d67caaa9d1 100644
--- a/library/TokenUtils.php
+++ b/library/TokenUtils.php
@@ -12,7 +12,7 @@ class TokenUtils
    * @return string
    * @throws Exception
    */
-  public static function generateToken (string $userDN, int $timeStamp): string
+  public static function generateToken (string $userDN, int $timeStamp, TaskGateway $gateway): string
   {
     $token = NULL;
     // Salt has been generated with APG.
@@ -28,7 +28,7 @@ class TokenUtils
     $token = Utils::base64urlEncode($token_hmac);
 
     // Save token within LDAP
-    self::saveTokenInLdap($userDN, $token, $timeStamp);
+    self::saveTokenInLdap($userDN, $token, $timeStamp, $gateway);
 
     return $token;
   }
@@ -64,17 +64,17 @@ class TokenUtils
 
 
     // Verify if token ou branch exists
-    if (!self::tokenBranchExist('ou=tokens' . ',' . $_ENV["LDAP_BASE"])) {
+    if (!self::tokenBranchExist('ou=tokens' . ',' . $_ENV["LDAP_BASE"], $gateway)) {
       // Create the branch
-      self::createBranchToken();
+      self::createBranchToken($gateway);
     }
 
     // The user token DN creation
     $userTokenDN = 'cn=' . $uid . ',ou=tokens' . ',' . $_ENV["LDAP_BASE"];
     // Verify if a token already exists for specified user and remove it to create new one correctly.
-    if (self::tokenBranchExist($userTokenDN)) {
+    if (self::tokenBranchExist($userTokenDN, $gateway)) {
       // Remove the user token
-      self::removeUserToken($userTokenDN);
+      self::removeUserToken($userTokenDN, $gateway);
     }
 
     // Add token to LDAP for specific UID
diff --git a/plugins/tasks/Reminder.php b/plugins/tasks/Reminder.php
index 8cda3fce0fb0c5e59b9278203c1abc8e1b4c08ea..1faeff7b2f67e7a6566461740190f9dc77209f20 100644
--- a/plugins/tasks/Reminder.php
+++ b/plugins/tasks/Reminder.php
@@ -113,7 +113,7 @@ class Reminder implements EndpointInterface
               $remindersMainTask[0]['fdtasksreminderfirstcall'][0],
               $remindersMainTask[0]['fdtasksremindersecondcall'][0]);
             // Create token for SubTask
-            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire);
+            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
             // Edit the mailForm with the url link containing the token
             $tokenMailTemplateForm = TokenUtils::generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
             // Recipient email form
@@ -140,7 +140,7 @@ class Reminder implements EndpointInterface
               $remindersMainTask[0]['fdtasksreminderfirstcall'][0],
               $remindersMainTask[0]['fdtasksremindersecondcall'][0]);
             // Create token for SubTask
-            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire);
+            $token = TokenUtils::generateToken($task['fdtasksgranulardn'][0], $tokenExpire, $this->gateway);
             // Edit the mailForm with the url link containing the token
             $tokenMailTemplateForm = TokenUtils::generateTokenUrl($token, $mailTemplateForm, $remindersMainTaskName);
             // Recipient email form