A python library for building and/or consuming LTI apps
Project description
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.
Installation
pip install lti
Dependencies
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.
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(
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)
from lti.contrib.django import DjangoToolProvider
from my_app import RequestValidator
# create the tool provider instance
secret = 'my LTI app oauth secret'
tool_provider = DjangoToolProvider.from_django_request(secret, 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
Testing
Unit tests can be run by executing
tox
This uses tox to set up and run the test environment.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lti-0.8.1.tar.gz
.
File metadata
- Download URL: lti-0.8.1.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67e0b6fccf7860811ac81c309154dfb574c3ccd84932b5d3476c878ac008b0e2 |
|
MD5 | 07401537ebba6e52642a75c95fc2e76c |
|
BLAKE2b-256 | 20d8eef1817548bc104a8b537cf03caa4c33bf778c6d85b39fc80190e9ba5d6e |
File details
Details for the file lti-0.8.1-py2.py3-none-any.whl
.
File metadata
- Download URL: lti-0.8.1-py2.py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0765811bad1af312fdc0e27798d0c8d1b3dbd1a4d86dc620675f4613bf2bf0d8 |
|
MD5 | 40474eb8c986c1a71415ab5cb4b22c7c |
|
BLAKE2b-256 | 0733fad7e1d7e637621b79dbfd9aec943a82ac8c7ef5dcc9b68d4c23aa08b8c6 |