protected function getUniqueToken()
    {
        $length = 64;

        if (function_exists('random_bytes')) {
            return base64_encode(random_bytes($length));
        }

        if (function_exists('openssl_random_pseudo_bytes')) {
            return base64_encode(openssl_random_pseudo_bytes($length));
        }

        if (function_exists('password_hash')) {
            // We're using a cost of only 4 since it's not a matter
            // of having a strong hash, but rather a random token
            return base64_encode(password_hash(uniqid(), PASSWORD_DEFAULT, [
                'cost' => 4
            ]));
        }

        // It seems like we don't have any decent librarues installed
        // that can produce a some what secure random string of bytes
        // so let's use some old method (which won't be as secure)

        // This is not a very cryptographically secure token, but without
        // any other extensions, you can't really do that much.

        $token = '';
        for ($i = 0; $i < 4; $i++) {
            $token .= uniqid(rand(0,10000));
        }

        return base64_encode(str_shuffle($token));
    }