Giter Club home page Giter Club logo

pylti1.3-django-example's Introduction

Example of usage PyLTI1p3 library within Django framework

PyLTI1p3 is a Python implementation of LTI 1.3 Advantage Tool.

First of all choose and configure test LTI 1.3 Platform. It may be:

The most simple way to check example is to use docker + docker-compose. Change the necessary configs in the configs/game.json (here is instruction how to generate your own public + private keys):

{
    "<issuer>" : [{ // This will usually look something like 'http://example.com'
        "default": true, // this block will be used in case if client-id was not passed
        "client_id" : "<client_id1>", // This is the id received in the 'aud' during a launch
        "auth_login_url" : "<auth_login_url>", // The platform's OIDC login endpoint
        "auth_token_url" : "<auth_token_url>", // The platform's service authorization endpoint
        "auth_audience": null, // The platform's OAuth2 Audience (aud). Is used to get platform's access token,
                               // Usually the same as "auth_token_url" but in the common case could be a different url
        "key_set_url" : "<key_set_url>", // The platform's JWKS endpoint
        "key_set": null, // in case if platform's JWKS endpoint somehow unavailable you may paste JWKS here
        "private_key_file" : "<path_to_private_key>", // Relative path to the tool's private key
        "public_key_file": "<path_to_public_key>", // Relative path to the tool's public key
        "deployment_ids" : ["<deployment_id>"] // The deployment_id passed by the platform during launch
    }, {
        "default": false,
        "client_id" : "<client_id2>",
        ...
    }]
}

and execute:

$ docker-compose up --build

You may use virtualenv instead of docker:

$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ cd game
$ python manage.py runserver 127.0.0.1:9001

Now there is game example tool you can launch into on the port 9001:

OIDC Login URL: http://127.0.0.1:9001/login/
LTI Launch URL: http://127.0.0.1:9001/launch/
JWKS URL: http://127.0.0.1:9001/jwks/

pylti1.3-django-example's People

Contributors

claytonturner avatar dependabot[bot] avatar dmitry-viskov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pylti1.3-django-example's Issues

Usability in custom LMS

Hi, I am building my own LMS and want to add support for LTI 1.3. Can I use this package for supporting LTI 1.3 on LMS too, or is it only meant for tools? If yes, can you provide some guidance?

Testing with Canvas issue

I am trying to test out the pylti1.3-django-example repo with our Canvas test instance, the LTI launch seems to be successful.
The problem I am facing is when trying to make api call with scoreboard for getting assignment grades I am seeing a 401
{"status":"unauthenticated","errors":[{"message":"user authorization required"}]}.
https://bff61e2a5520.ngrok.io/api/scoreboard/lti1p3-launch-507-478c-a893-649c5d665d12/
and the log reflects this

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
   File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
     response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/game/game/views.py", line 208, in scoreboard
   scores = ags.get_grades(score_line_item)
   File "/usr/local/lib/python3.6/site-packages/pylti1p3/assignments_grades.py", line 99, in get_grades
     line_item = self.find_or_create_lineitem(line_item, find_by=find_by)
   File "/usr/local/lib/python3.6/site-packages/pylti1p3/assignments_grades.py", line 70, in find_or_create_lineitem
    line_item = self.find_lineitem_by_tag(new_line_item.get_tag())
  File "/usr/local/lib/python3.6/site-packages/pylti1p3/assignments_grades.py", line 60, in find_lineitem_by_tag
     line_items = self.get_lineitems()
  File "/usr/local/lib/python3.6/site-packages/pylti1p3/assignments_grades.py", line 46, in get_lineitems
   accept='application/vnd.ims.lis.v2.lineitemcontainer+json'
  File "/usr/local/lib/python3.6/site-packages/pylti1p3/service_connector.py", line 86, in make_service_request
   raise LtiException('HTTP response [%s]: %s - %s' % (url, str(r.status_code), r.text))
 pylti1p3.exception.LtiException: HTTP response [https://something.test.instructure.com/api/lti/courses/2324424/line_items]: 401 - {"status":"unauthenticated","errors":[{"message":"user authorization required"}]}

LTI Launch works and Deep links work as well. I just git cloned this repo and tried it so all the pip version are as required.
Screen Shot 2020-06-18 at 4 17 02 PM
Can you suggest what's going on?

Updated example to use DjangoDbToolConf?

Do you have any updated example of this code to use the newerpylti1p3.contrib.django.DjangoDbToolConf rather than having to define the json file?

I was going to start another app based on this pattern and figured if you didn't I might just update this example as a better starting point. Hasn't seemed like a lot to add, there's just no default database configuration built into this.

Thanks!

Missing "target_link_uri" param

Hi there!
First of all , Thanks for making python package of LTI.I am trying to hit [localhost:9001/login](localhost url) but it says :

Missing "target_link_uri" param

There is no suck key exists in game.json , however I have target_link_uri : see this. I am running docker-compose up --build .Also after successfully running this repo , will we be certified ? because I already successfully published testing tool here : (https://lti-ri.imsglobal.org/platforms/1366)
Could you please help me out ?

Werkzeug throws LtiException: Missing id_token

I'm getting this when I try to access this tool from the development version of canvas.docker. Canvas docker also has a SSL certificate installed. I've used Werkzeug on the pylti1.3-django-example app.

I'm runing the Django app like this (no docker):

python manage.py runserver_plus --cert-file cert.pem --key-file key.pem 9001

I get the following, I feel like I'm missing something really basic but I'm stuck on this one.

image

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.