跳到主要内容

Personal access tokens

The user needs to perform several easy steps to pass authentication:

  1. Send POST request, containing the userName and password parameters to the api/2.0/authentication address:

    POST /api/2.0/authentication HTTP/1.1
    Host: yourportal.onlyoffice.com
    Content-Type: application/json
    Accept: application/json

    {
    "userName": "yourusername",
    "password": "yourpassword"
    }

    Please note, that you have to enter your own portal address to the Host: yourportal.onlyoffice.com line instead of yourportal.onlyoffice.com address.

  2. In case authentication is successful, a token and its lifetime will be received.

  3. Use this token every time you call API methods inserting it to the Authorization HTTP header:

    Example API Request:

    GET /api/2.0/people/@self HTTP/1.1
    Host: yourportal.onlyoffice.com
    Accept: application/json
    Authorization: sdjhfskjdhkqy739459234

    Please note, that you have to enter your own portal address to the Host: yourportal.onlyoffice.com line instead of yourportal.onlyoffice.com address.

Authentication request examples

const axios = require("axios");

async function authenticate() {
try {
const response = await axios.post("https://yourportal.onlyoffice.com/api/2.0/authentication", {
userName: "yourusername",
password: "yourpassword"
}, {
headers: {
"Content-Type": "application/json"
}
});

console.log(response.data);
} catch (error) {
console.error("Authentication failed:", error.response?.data || error.message);
}
}

authenticate();

Please note, that you have to enter your own portal address, username and password instead of yourportal.onlyoffice.com, yourusername and yourpassword respectively.