dbos
1 April 2024 18:56
1
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>
<script>
docSpace=DocSpace.SDK
docSpace.login ("mymail","mypassword")
var ds=docSpace.initFrame();
</script>
…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 );
getHashSettings
createHash
login
dbos
3 April 2024 11:11
3
Yes, I tried that. But (after docSpace=DocSpace.SDK) docSpace.getHashSettings just returns an empty array. And so does docSpace.createHash, of course.
@dbos
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 .
dbos
4 April 2024 14:43
5
Thank you for your answer.
I am on free Startup Cloud Docspace.
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.
Hi @dbos
I have some news for you!
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
Additionally, We’ve added script 8507.html using passwordHash and hashSettings. Be sure to check it out:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="ds-frame">Fallback text</div>
<script src="http://.../static/scripts/sdk/1.0.0/api.js"></script>
<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) {
DocSpace.SDK.initManager(config);
} 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) {
console.error(e);
}
}
}
}
};
DocSpace.SDK.initSystem({...config, ...systemConfig});
</script>
</body>
</html>
dbos
24 April 2024 17:38
13
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
1 Like