Skip to main content

A python library for building and/or consuming LTI apps. Forked from

Project description

This library is a fork of lti_lti_py It has been modified to accept non-standard params and bubble up useful error messages in the form of exceptions to the caller.

lti is a Python library implementing the Learning Tools Interoperability (LTI) standard. It is based on lti_lti_py, which is based on dce_lti_py, which is based on ims_lti_py.


pip install lti



The primary goal of this library is to provide classes for building Python LTI tool providers (LTI apps). To that end, the functionality that you’re looking for is probably in the ToolConfig and ToolProvider classes (ToolConsumer is available too, if you want to consume LTI Providers).

Tool Config Example (Django)

Here’s an example of a Django view you might use as the configuration URL when registering your app with the LTI consumer.

from lti import ToolConfig
from django.http import HttpResponse

def tool_config(request):

    # basic stuff
    app_title = 'My App'
    app_description = 'An example LTI App'
    launch_view_name = 'lti_launch'
    launch_url = request.build_absolute_uri(reverse('lti_launch'))

    # maybe you've got some extensions
    extensions = {
        'my_extensions_provider': {
            # extension settings...

    lti_tool_config = ToolConfig(
        description = app_description

    return HttpResponse(lti_tool_config.to_xml(), content_type='text/xml')

Tool Provider OAuth Request Validation Example (Django)

from lti.contrib.django import DjangoToolProvider
from my_app import RequestValidator
from oauthlib.oauth1 import SignatureOnlyEndpoint

# create the tool provider instance
tool_provider = DjangoToolProvider.from_django_request(request=request)

# the tool provider uses the 'oauthlib' library which requires an instance
# of a validator class when doing the oauth request signature checking.
# see for
# info on how to create one
validator = RequestValidator()

# validate the oauth request signature
ok = tool_provider.is_valid_request(SignatureOnlyEndpoint, validator)

# do stuff if ok / not ok

Tool Consumer Example (Django)

In your view:

def index(request):
    consumer = ToolConsumer(
            'lti_message_type': 'basic-lti-launch-request'

    return render(
            'launch_data': consumer.generate_launch_data(),
            'launch_url': consumer.launch_url

At the template:

<form action=<s>"{{ launch_url }}"</s>
  {% for key, value in launch_data.items %}
    <input type=<s>"hidden"</s> name=<s>"{{ key }}"</s> value=<s>"{{ value }}"</s>/>
  {% endfor %}
  <button type=<s>"submit"</s>>Launch the tool</button>


Unit tests can be run by executing


This uses tox to set up and run the test environment.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

e-lti-0.9.5.tar.gz (15.4 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page