How to access Docspace through Javascript SDK

I’m trying to access my DocSpace through Javascript SDK in a web page.
This is my code

<script> src="https://.../static/scripts/api.js"</script>
<iframe id="ds-frame"></iframe>
docSpace.login ("mymail","mypassword")
var ds=docSpace.initFrame();

…and I am still asked to enter my mail and password despite of the login method.

Any help ?

Manty thanks and apologize may english

Hi @dbos

So, are you entering a password?
Or are you using a password hash?

docSpace.login(email, passwordHash);

  1. getHashSettings
  2. createHash
  3. login

Yes, I tried that. But (after docSpace=DocSpace.SDK) docSpace.getHashSettings just returns an empty array. And so does docSpace.createHash, of course.

We’ll need to check this behavior.
Please clarify which version of DocSpace you are using, OS and the installation method. (exe/ Docker/ DEB/RPM packages)

I assume you used instructions from our Help Center.

Thank you for your answer.

I am on free Startup Cloud Docspace.

No more answer ?

Hi @dbos
We will check the behavior for getHashSettings.

As soon as I receive information or if we have additional questions, I will get back to you.

Ok, thanks.

Hi @dbos

I have some news for you!

  1. We’ve released ONLYOFFICE DocSpace 2.5.

In this release, we’ve added ready-to-use presets that allow you to seamlessly embed your DocSpace or its parts into any web interface. You can embed the whole DocSpace, Public room, Editor or Viewer, Room or File selector, as well as use Custom mode to configure all the parameters manually.

Where to find: Settings → Developer Tools → JavaScript SDK

  1. Additionally, We’ve added script 8507.html using passwordHash and hashSettings. Be sure to check it out:
<!doctype html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <div id="ds-frame">Fallback text</div>
    <script src="http://.../static/scripts/sdk/1.0.0/api.js"></script>
      const email = "...";
      const password = "...";

      const config = {
        frameId: "ds-frame",
        width: "1200px",
        height: "800px",
        showMenu: true,
        events: {
          "onSignOut": () => DocSpace.SDK.initSystem({...config, ...systemConfig})

      const systemConfig = {
        events: {
          "onAppReady": async () => {
              const user = await DocSpace.SDK.frames[config.frameId].getUserInfo();

              if (user?.email === email) {
              } else {
                await DocSpace.SDK.frames[config.frameId].logout();

                const hashSettings = await DocSpace.SDK.frames[config.frameId].getHashSettings();
                const passwordHash = await DocSpace.SDK.frames[config.frameId].createHash(password, hashSettings);

                try {
                  DocSpace.SDK.frames[config.frameId].login(email, passwordHash).then(() => DocSpace.SDK.initManager(config));
                } catch (e) {

    DocSpace.SDK.initSystem({...config, ...systemConfig});


Thanks for your reply. The web page example works well!
I’m not sure I understood everything in the code, but I’ll study it carefully :slight_smile:

1 Like