Skip to main content
====================================
lti: Learning Tools Interoperability
====================================

.. image:: https://travis-ci.org/pylti/lti.svg?branch=master
:target: https://travis-ci.org/pylti/lti

.. image:: https://codecov.io/gh/pylti/lti/branch/master/graph/badge.svg
:target: https://codecov.io/gh/pylti/lti

.. image:: https://badges.gitter.im/pylti/lti.svg
:alt: Join the chat at https://gitter.im/pylti/lti
:target: https://gitter.im/pylti/lti?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

.. image:: https://requires.io/github/pylti/lti/requirements.svg?branch=master
:target: https://requires.io/github/pylti/lti/requirements/?branch=master
:alt: Requirements Status

``lti`` is a Python library implementing the
Learning Tools Interperability (LTI) standard.
It is based on dce_lti_py_,
which is based on ims_lti_py_.

.. _dce_lti_py: https://github.com/harvard-dce/dce_lti_py
.. _ims_lti_py: https://github.com/tophatmonocle/ims_lti_py


Installation
============

.. code-block:: sh

pip install lti


Dependencies
============

* lxml_
* oauthlib_
* requests-oauthlib_

.. _lxml: https://github.com/lxml/lxml
.. _oauthlib: https://github.com/idan/oauthlib
.. _requests-oauthlib: https://github.com/requests/requests-oauthlib


Usage
=====

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.

.. code-block:: python

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(
title=app_title,
launch_url=launch_url,
secure_launch_url=launch_url,
extensions=extensions,
description = app_description
)

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


Tool Provider OAuth Request Validation Example (Django)
-------------------------------------------------------

.. code-block:: python

from lti.contrib.django import DjangoToolProvider
from my_app import RequestValidator


# 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 https://oauthlib.readthedocs.org/en/latest/oauth1/validator.html for
# info on how to create one
validator = RequestValidator()

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

# do stuff if ok / not ok


Tool Consumer Example (Django)
----------------------------

In your view:

.. code-block:: python

def index(request):
consumer = ToolConsumer(
consumer_key='my_key_given_from_provider',
consumer_secret='super_secret',
launch_url='provider_url',
params={
'lti_message_type': 'basic-lti-launch-request'
}
)

return render(
request,
'lti_consumer/index.html',
{
'launch_data': consumer.generate_launch_data(),
'launch_url': consumer.launch_url
}
)

At the template:

.. code-block:: html

<form action="{{ launch_url }}"
name="ltiLaunchForm"
id="ltiLaunchForm"
method="POST"
encType="application/x-www-form-urlencoded">
{% for key, value in launch_data.items %}
<input type="hidden" name="{{ key }}" value="{{ value }}"/>
{% endfor %}
<button type="submit">Launch the tool</button>
</form>


Testing
=======

Unit tests can be run by executing

.. code-block:: sh

tox

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

.. _tox: https://tox.readthedocs.org/

Release files for lti 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lti 0.9.0
File Size Uploaded
lti-0.9.0.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lti 0.9.0
File Interpreter ABI Platform
lti-0.9.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 35.3 kB

Release files / lti-0.9.0.tar.gz

Download URL lti-0.9.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1c0884fa6c290b1f648c6815976e92f03ed891e0a16d3cac61c65ae7971b071a
BLAKE2b-256 checksum
How to use checksums
54d2874e497dce21872d673bd9c58f27600790c11b7fbc6c915e1f6cd78beb58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / lti-0.9.0-py2.py3-none-any.whl

Download URL lti-0.9.0-py2.py3-none-any.whl
Size 21.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
48b4b94f7654b85e61c3e5cf6b80b592e5253d9ae43e81a21b62604769813909
BLAKE2b-256 checksum
How to use checksums
8c90abe130927a47ac5fdc4e1b27b433c425dfc5009ea51655d0794ad21bc222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

This release

0.9.0 This release

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page