Giter Site home page Giter Site logo

dce_lti_py's Introduction

dce_lti_py

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

dce_lti_py is a fork of ims_lti_py.

Installation

Install via pip:

pip install dce_lti_py

Dependencies

Usage

The primary goal of this library is to provide classes for building python LTI tool providers (i.e., LTI apps). To that end, the functionality 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 dce_lti_py 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)

Here's an example of how you would validate an incoming LTI launch request. You'd probably do this as part of some auth middleware, e.g., django-auth-lti

    from dce_lti_py.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

ims-lti-py unit tests can be run by executing

python setup.py test

Optionally, you can use tox with the provided tox.ini file

dce_lti_py's People

Contributors

amackera avatar brainheart avatar iceraj avatar jsutlovic avatar kajigga avatar lbjay avatar michaelwheeler avatar muayyad-alsadi avatar rgutierrez-cotech avatar riggs avatar sontek avatar virajkanwade avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.