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:
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 browserid_info tag, such as the parameters for the Persona popup.

Returns:Object containing the data from the info tag.
getCsrfToken()

Fetch a CSRF token from the CsrfToken view via an AJAX request.

Returns:Deferred that resolves with the CSRF token.
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.