📝 Merge auth example with existing one

This commit is contained in:
Gina Häußge committed 2021-02-16 17:21:19 +01:00
1 parent 47eeb0eb00
commit 281c4b698c
3 files changed
+24 -15

No files matched your search

+18
View File
@@ -114,9 +114,13 @@
Instructs the server to decrease the message rate by 500ms.
.. _sec-jsclient-socket-authsample:
Sample to setup an authed socket
================================
If you have a username and a password:
.. code-block:: javascript
OctoPrint.socket.connect();
@@ -125,6 +129,20 @@ Sample to setup an authed socket
OctoPrint.socket.sendAuth("myusername", response.session);
});
If you have an API key:
.. code-block:: javascript
var client = new OctoPrintClient({
baseurl: "http://example.com/",
apikey: "abcdef"
});
client.socket.connect();
client.browser.passiveLogin()
.done(function(response) {
client.socket.sendAuth(response.name, response.session);
});
.. _sec-jsclient-socket-throttling:
Communication Throttling