2017-01-20 10:34:19 +00:00
|
|
|
.. _sec-jsclientlib-browser:
|
2016-06-15 07:47:32 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
:mod:`OctoPrintClient.browser`
|
|
|
|
|
------------------------------
|
2016-06-15 07:47:32 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
.. js:function:: OctoPrintClient.browser.login(username, password, remember, opts)
|
2016-06-15 07:47:32 +00:00
|
|
|
|
|
|
|
|
Logs the browser into OctoPrint, using the provided ``username`` and
|
|
|
|
|
``password`` as credentials. If ``remember`` is set to ``true``, the session
|
|
|
|
|
will also persist across browser restarts.
|
|
|
|
|
|
2016-06-29 07:28:55 +00:00
|
|
|
**Example:**
|
|
|
|
|
|
|
|
|
|
.. code-block:: javascript
|
|
|
|
|
|
|
|
|
|
OctoPrint.browser.login("myusername", "mypassword", true)
|
|
|
|
|
.done(function(response) {
|
|
|
|
|
// do something with the response
|
|
|
|
|
});
|
|
|
|
|
|
2016-06-15 07:47:32 +00:00
|
|
|
:param string username: Username to log in with
|
|
|
|
|
:param string password: Password to log in with
|
|
|
|
|
:param bool remember: "Remember me"
|
|
|
|
|
:param object opts: Additional request options
|
2016-06-29 07:28:55 +00:00
|
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
2016-06-15 07:47:32 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
.. js:function:: OctoPrintClient.browser.passiveLogin(opts)
|
2016-06-15 07:47:32 +00:00
|
|
|
|
|
|
|
|
Tries to perform a passive login into OctoPrint, using existing session data
|
|
|
|
|
stored in the browser's cookies.
|
|
|
|
|
|
|
|
|
|
:param object opts: Additional request options
|
2016-06-29 07:28:55 +00:00
|
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|
2016-06-15 07:47:32 +00:00
|
|
|
|
2017-01-20 10:34:19 +00:00
|
|
|
.. js:function:: OctoPrintClient.browser.logout(opts)
|
2016-06-15 07:47:32 +00:00
|
|
|
|
|
|
|
|
Logs the browser out of OctoPrint.
|
|
|
|
|
|
|
|
|
|
:param object opts: Additional request options
|
2016-06-29 07:28:55 +00:00
|
|
|
:returns Promise: A `jQuery Promise <http://api.jquery.com/Types/#Promise>`_ for the request's response
|