JavaScript API¶
This part of the documentation describes the JavaScript API defined in api.js that can be used to interact with Persona or the django-browserid views on your server.
- django_browserid¶
Global object containing the JavaScript API for interacting with django-browserid.
Most functions return jQuery Deferreds for registering asynchronous callbacks.
- login([requestArgs])¶
Retrieve an assertion and use it to log the user into your site.
Arguments: - requestArgs (object) – Options to pass to navigator.id.request.
Returns: Deferred that resolves once the user has been logged in.
- logout()¶
Log the user out of your site.
Returns: Deferred that resolves once the user has been logged out.
- getAssertion([requestArgs])¶
Retrieve an assertion via BrowserID.
Returns: Deferred that resolves with the assertion once it is retrieved.
- verifyAssertion(assertion)¶
Verify that the given assertion is valid, and log the user in.
Arguments: - assertion (string) – Assertion to verify.
Returns: Deferred that resolves with the login view response once login is complete.
- getInfo()¶
Fetch information from the Info view, such as a CSRF token or the parameters for the Persona popup.
Returns: Deferred that resolves with the results of the AJAX request.
- didLoginFail([location])¶
Check for the query string parameter used to signal a failed login.
Arguments: - location (string) – Location object containing the URL to check. Defaults to window.location.
Returns: True if the parameter was found and login failed, false otherwise.