WARN [327] localhost - ASC.Core - Can not decrypt cookie

Hello Guys,

I have ONLYOFFICE Workspace Community running on ubuntu 22.04 for a year now (NON-Docker Version) And everything was running fine TILL yesterday.

I will explain my setup:

SERVER A = PHP WebServer
SERVER B = OnlyOffice Workspace

On server A there will be a XLSX file generated and it will be uploaded to SERVER B via a JWT TOKEN.

This script was uploading the file to (server B) the OnlyOffice Workspace succesfully:


<?php

// UPLOAD XLSX TO SERVER B
$token = "MyTokenHere=";
$apiUrl = "https://office.mydomain.com/api/2.0";

// Authenticate and get a token
function authenticate($apiUrl, $authCredentials) {
    $authEndpoint = "$apiUrl/authentication.json";

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $authEndpoint);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($authCredentials));

    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        throw new Exception("Curl error: " . curl_error($ch));
    }

    curl_close($ch);
    $data = json_decode($response, true);

    if (!isset($data["response"]["token"])) {
        throw new Exception("Authentication failed. Response: " . $response);
    }

    return $data["response"]["token"];
}

// Upload file
function uploadFile($apiUrl, $folderId, $filePath, $token) {
    $uploadEndpoint = "$apiUrl/files/$folderId/upload";

    if (!file_exists($filePath)) {
        throw new Exception("File not found: $filePath");
    }

     $originalFileName = basename($filePath); // Extract original file name
    // Use preg_replace with a limit of 1 for the first underscore
    $fileName = preg_replace('/_/', ' ', $originalFileName, 1);

    // Use preg_replace with a limit of 1 and offset
    $fileName = preg_replace('/_/', '    ', $fileName, 1);


    $fileInfo = new CURLFile($filePath, mime_content_type($filePath), $fileName);  // Attach the file and set the MIME type (using modified name)

    // Prepare POST data with the file
    $postData = [
        "file" => $fileInfo, // Attach the file
        "title" => $fileName  // Explicitly set the file name (with spaces)
    ];

    // Initialize the cURL request
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $uploadEndpoint);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        "Authorization: Bearer $token",
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

    // Execute the request
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        throw new Exception("Curl error: " . curl_error($ch));
    }

    curl_close($ch);
    $data = json_decode($response, true);

    if (!isset($data["response"])) {
        throw new Exception("File upload failed. Response: " . $response);
    }

    return $data["response"];
}

?>

But since yesterday it stopped with uploading the generated files to SERVER B.
I have checked the logs and i see this error:

2025-06-19 11:52:48,750 **WARN** [327] localhost - ASC.Core - Can not decrypt cookie: Bearer MyTokenHere= from 192.99.167.110 for https://office.mydomain.com/api/2.0/files/62/upload

Is my JWT token expired? How can i check the expire date of the JWT token?
Do i need to generate a NEW token? If yes, how can i do that?

3 posts were merged into an existing topic: File upload is not correctly uploading via API