diff --git a/lib/private/share/constants.php b/lib/private/share/constants.php
index 1ba4929899a41d061ffb701716908d004935f375..798327cc154d471f58278fe1768e95c9a1e20e89 100644
--- a/lib/private/share/constants.php
+++ b/lib/private/share/constants.php
@@ -34,6 +34,8 @@ class Constants {
 	const FORMAT_STATUSES = -2;
 	const FORMAT_SOURCES = -3;  // ToDo Check if it is still in use otherwise remove it
 
+	const TOKEN_LENGTH = 15; // old (oc7) length is 32, keep token length in db at least that for compatibility
+
 	protected static $shareTypeUserAndGroups = -1;
 	protected static $shareTypeGroupUserUnique = 2;
 	protected static $backends = array();
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index fe62f4f005e7e337d33ce69a204550a996e22ced..8441e6a94c44a5e7b7007c6db63a5aef1734cff8 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -640,7 +640,7 @@ class Share extends \OC\Share\Constants {
 				if (isset($oldToken)) {
 					$token = $oldToken;
 				} else {
-					$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($tokenLength,
+					$token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH,
 						\OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
 						\OCP\Security\ISecureRandom::CHAR_DIGITS
 					);